What are a consumer and a producer?

C - 1 Producer 2 Consumer problem?

  • I know how to solve the 1 producer 1 consumer problem. It was something like this. The producer produced 1 item and stored it into the buffer. The producer blocks until the consumer ...show more

  • Answer:

    This problem isn't particularly interesting in C. It only becomes interesting in the context of some operating system environment where threads or processes exist in the face of pre-emptive switching. I've no idea what calls you are permitted to make here. Are you implementing a "lock" using a binary semaphore? I don't know. Also, the design you provided doesn't seem workable. Suppose producer grabs 'mutex' and then sits waiting on 'parent' to be notified/signaled. The consumer can't get mutex, so it can't signal. What you have looks like half of a monitor-based system. But I don't see the monitor. See link below for a reasonable discussion here.

D2NBZS7UNNDCTCPIZPQHRJ7UUQ at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.