Skip to content

In this practical I wrote an array-based implementation of a dynamically-chosen fixed-size generic Queue in C, and a thread-safe, blocking queue.

Notifications You must be signed in to change notification settings

ChedySmaoui/Queues-and-Thread-Safety

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Quees and Thread Safety in C

Please give me a star if this was useful to you!

Overview

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.

Grade Received: 20/20

1. How to build

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.

2. Project Overview

  1. 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.

  2. 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.

  3. Makefile The Makefile has not been edited.

3. Testing Framework

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.

About

In this practical I wrote an array-based implementation of a dynamically-chosen fixed-size generic Queue in C, and a thread-safe, blocking queue.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published