Bounded buffer by using Semaphores!!

Here's the code i generated but having errors.... with these in hand,
Semaphore empty = 0; semaphore full = N; semaphore mutex = 1;

Code structure for producer Code structure for Consumer

Do{ do {
Wait (mutex);
Produce another item Wait (full);
. .
Wait (mutex); Remove the next item from buffer
Wait (empty);
Signal (empty);
Add the new item into the buffer Signal (mutex);
Signal (full); Consume the new item
Signal (mutex); .
While (1); While (1);
} }

anybody there to pass any help or comment but at your earliest!!!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!