Question: Given the two semaphore operations illustrated below; And using ( as an example and basis ) the producer - consumer code as illustrated below; `
Given the two semaphore operations illustrated below;
And using as an example and basis the producerconsumer code as illustrated below;
Producer
while true
item produceitem
waitempty
waitbinary
additemtobufferitem
signal binary
signalfull
Consumer
l
while true
waitfull;
waitbinary;
takeitemfrombufferitem;
signal binary;
signal empty;
consumeitemitem
Then given the following information;
Three processes are involved in printing a file pictured below;
Process A reads the file data from the disk to Buffer
Process B copies the data from Buffer to Buffer
Process C takes the data from Buffer and prints it
Assume all three processes operate on one file record at a time, both buffers' capacity are one record.
Write pseudo code in the style of the producerconsumer to coordinate the three processes using semaphores and successfully print a file.
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
