Question: Question 1 The following program in Erlang implements the Producers / Consumers synchronization pattern using message passing. It is missing the implementation of loopPC /
Question The following program in Erlang implements the ProducersConsumers synchronization pattern using message passing. It is missing the implementation of loopPC which you are asked to complete. The arguments to loopPC are as follows: Cs: Number of consumers that started consuming Ps: Number of producers that started producing MaxBuffersize: Buffer size constant greater than OccupiedSlots: Number of currently occupied slots in the buffer Note: Multiple producers and consumers should be allowed. consumer Id Buffer timer : sleep io: fwrite Consumer p trying to consume nI d Ref makeref Buffer startconsume, self Ref receive oktoconsume, Ref io: fwrite Consumer p consuming nI d Buffer endconsume io: fwrite Consumer p stopped consuming nI d consumer Id Buffer end producer Id Buffer timer : sleep io: fwrite Producer p trying to produce n Id Ref makeref Buffer startproduce, self Ref receive oktoproduce, Ref io: fwrite Producer p producing nI d Buffer endproduce io: fwrite Producer p stopped producing nI d producer Id Buffer end loopPC Cs Ps MaxBufferSize, ccupiedSlots implement me startPC Buffer spawn fun loopPC end spawn fun producer Id Buffer end Id lists : seq spawn fun consumer Id Buffer end Id lists: seq
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
