Atomic Broadcast Problem (based roughly on Exercise 6.16 in Reference [7]). A single slot integer buffer is shared by one producer process and $N$ consumer processes. The producer repeatedly deposits messages into the buffer; consumers repeatedly fetch messages from the buffer.
(a) A given message is fetched by any $N$ processes, not necessarily all $N$ processes. That is, a given message might be fetched multiple times by some processes and not at all by other processes.
Does your solution also work if there are multiple producers? Explain. (Address multiple producers only in this particular part; do not use multiple producers in your solutions to any other parts of this question.)
(b) Modify your solution to the previous part so that each consumer process fetches exactly once each message the producer deposits.
(c) Modify your solution to the previous part so that only the consumer processes waiting (if any) when the producer deposits a message get to fetch that message.
Your solution must be structurally similar to the ResourceAllocatorMultiple code in Section 7.4. This problem requires three kinds of processes that interact with only the indicated interfaces:
- producer - similar to a client. It interfaces to the coordinator by send request(DEPOSIT, UNUSED, somevalue); receive preply();
- consumer, with identity i between 0 and $N-1-$ similar to a client. It interfaces to the coordinator by
send request (FETCH, $i$, UNUSED);
receive creply[i] (somevariable);
- coordinator - similar to the server; it holds the buffer and synchronizes access to it.
Use only send and receive (no inni, call, reply, forward, etc.).