Please give me a star if this was useful to you!
This is an array-based implementation of a dynamically chosen fixed-size generic queue in C with unit tests ensuring the correct operation of our queue. It also contains an extended implementation of the first Queue implementation providing a thread-safe blocking queue implementation and unit tests for our Blocking Queue.
See Makefile for the build scripts.
To build both the TestQueue and TestBlockingQueue executables, simply run make at the command line in the current directory.
To run the test suites, run ./TestQueue for testing the Queue and ./TestBlockingQueue for testing the BlockingQueue.
Important: the command make clean will try to delete any executable or .o files in the src directory.
-
Blocking Queue: My program implementation is in BlockingQueue.c where you will find all the functions defined in the header file implemented as required. You will also find a new static function private to the BlockingQueue.c file called clean_exit() which is a small helper function for cleanup and error handling of the functions from the POSIX library. The BlockingQueue's header file has been edited to add MACRO definitions as well as defining the BlockingQueue struct.
-
Queue My program implementation is in Queue.c where where you will find all the functions defined in the header file implemented as required. No helper functions were needed for the non-thread safe queue. The Queue's header file has been edited to add MACRO definitions as well as defining the Queue struct.
-
Makefile The Makefile has not been edited.
To run the test suites, run ./TestQueue for testing the Queue and ./TestBlockingQueue for testing the BlockingQueue.
The BlockingQueue's test suite contains 27 unit tests, some with several assertions. the Queue's test suite contains 22 unittests, some with several assertions.
The ./TestBlockingQueue can be a bit slow to execute because of the several sleep() calls ensuring that enq and deq threads wait when expected to.