0

In message-passing (producer-consumer) a Blocking send happens when the sending process is blocked until the message is received by the receiving process or by the mailbox.

A Blocking receive instead is when the receiver blocks until a message is available.

The solution to the producer–consumer problem becomes trivial when we use blocking send() and receive() statements.

Why it becomes trivial ?

2
  • Because it synchronises the sender and receiver?
    – Kusalananda
    Feb 16, 2018 at 18:45
  • The book doesnt explain this
    – Qwerto
    Feb 16, 2018 at 19:39

2 Answers 2

1

The book ("Operating System Concepts" - Silberschatz, Galvin, Gagne) you appear to be quoting has this to say on the subject:

Different combinations of send() and receive() are possible. When both send() and receive() are blocking, we have a rendezvous between the sender and the receiver. The solution to the producer-consumer problem becomes trivial when we use blocking send() and receive() statements. The producer merely invokes the blocking send() call and waits until the message is delivered to either the receiver or the mailbox. Likewise, when the consumer invokes receive(), it blocks until a message is available.

It seems pretty clear to me.

1
  • So, it synchronises the sender and receiver. :-)
    – Kusalananda
    Feb 16, 2018 at 21:22
0

The answer to your question is: please try to implement a solution to the consumer-producer problem where reading and writing are non-blocking.

If you do so, that is if you think about how to solve the problem with non-blocking read/write operations, you will quickly discover, that you need to do buffer management. Then you'll discover that in a concurrent situation you have to deal with reader/writer fairness etc. The problem gets multifaceted very quickly, with some of the sub-problems (fairness) having no obvious solution.

Not the answer you're looking for? Browse other questions tagged .