Hello All
I need to write a program in C standard to solve the produce -consumer problem
but I don't want to use threads, also I don't want to use Semaphore or shared memory.
The exactly I need is to write the program using (Message queue)
which use functions of (msgget-msgsnd-msgrcv-msgctl)
Can anybody help me?
:confused:

What OS are you using???

What OS are you using???

Linux

In producer-consumer problem, there is a value that both sides need to access right??

So, what you need to do is, each time you produce, you pass the value to customer, so they know how many is available, and whenever you consume one, you pass the remaining to inform the producer how many products is left. Use the functions you mentioned to send and receive the number of products.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.