Blocking Queues in C

Mar 27, 2024

I have used codeblocks software in Windows OS for C code compilation and execution. It is pretty good.

I attempted to use the rdtsc assembly instruction to obtain the processor timestamp. I added this instruction before and after invoking a function. However, I noticed that in some cases, the final timestamp value was lower than the initial timestamp value, without any overlap between the two.

Blocking queues are typically used for producer-consumer scenarios, and they become blocked when full or empty.

I used pthread library here. pthread library provides pthread functions for the creation of threads and mutex functions for synchronization. pthread library also provides pthread_cond_t variables and functions for conditional blocking.

Here is my implementation: