Question: This project will demonstrate two processes acting as a producer and consumer in the language C + + . The program should create named semaphores
This project will demonstrate two processes acting as a producer and consumer in the language C
The program should create named semaphores which both parent and child can access. It should then create a block of shared memory that will serve as a shared buffer. The producer should begin placing numbers to into the shared buffer while the consumer begins getting the numbers out of the buffer and printing them. The buffer should hold numbers. The actions should be coordinated using semaphores, as shown in slides and of the chapter slides.
Producer Process:
do
produce an item in nextproduced
waitempty;
waitmutex;
add next produced to the buffer
signalmutex;
signalfull;
while true;
Consumer Process:
Do
waitfull;
waitmutex;
remove an item from buffer to nextconsumed
signalmutex;
signalempty;
consume the item in next consumed
while true;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
