producer consumer problem
Define an integer buffer with the size of 32 and implement a circular queue data structure that is used by producers and a consumer. Next, you will need to initialize the mutex lock and semaphores. In this assignment, you will use two semaphores where one indicates a full queue and the other indicates an empty queue. The producer function is used to insert a random number between 0 and 10 to the queue. The consumer function is used to remove a number from the queue in a FIFO fashion. In addition, inside the loops of the producer and consumer functions, add a random delay between 0 and 2 seconds to simulate various lengths of processes. In addition, you are required to use 2 producers and 1 consumer for this assignment where 0 and 2 are producers and 1 is consumer (3 threads). Finally, your code should run forever.
6 years ago
10
- CIS 512 - Week 3 Discussion - CPUs and Programming
- Time Perception as We Age
- N high qualified A+
- History homework help
- PHL458 Week 3 Evaluating Truth and Validity Exercise
- Research Paper
- The instructions are attached
- statistic
- EDU 382 Meeting the Needs of Diverse Learners: Week 5 DQ 2
- Week 1 Discussion - A Brawl in Mickey's Backyard