Month: June 2011

Simple Example of Multithreading in C Linux

This simple example demonstrates the use of multithreading in the linux environment. This little piece of C code has two threads, a producer thread and a consumer thread. The producer thread generates 600 random numbers, which are passed one at a time to a consumer thread via shared memory. Both threads sum all of the random numbers. The fact that both the producer and consumer have the same sum is proof that the thread are communicating together correctly. /* * File: CS314_P01_BKT.c * Author: BK Turley * */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <sys/sem.h> […]

Binary Search Tree implemented. C++

This is my personal implementation of a binary search tree. My tree uses iteration instead of recursion for its insertion, deletion and searches for faster execution because function stack overhead is avoided. Recursion is still used for tree deletion because I didn’t want to implement a stack for the traversal of the tree which is required for deletion. // SearchableADT test driver // Copyright (C) 2011 Kyle Turley // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, […]