0% found this document useful (0 votes)
222 views10 pages

Bounded Buffer Problem Explained

The document discusses the bounded buffer problem, which is a synchronization problem where a producer produces items and puts them into a fixed-size buffer that is shared with a consumer. The consumer removes items from the buffer and consumes them. Semaphores are used to control access to the buffer so that the producer and consumer do not access it at the same time. The producer uses wait and signal operations on semaphores to add items to the buffer and the consumer does the same to remove items.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
222 views10 pages

Bounded Buffer Problem Explained

The document discusses the bounded buffer problem, which is a synchronization problem where a producer produces items and puts them into a fixed-size buffer that is shared with a consumer. The consumer removes items from the buffer and consumes them. Semaphores are used to control access to the buffer so that the producer and consumer do not access it at the same time. The producer uses wait and signal operations on semaphores to add items to the buffer and the consumer does the same to remove items.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
  • Introduction to Bounded Buffer Problem
  • Producer Consumer Problem Diagram
  • Semaphore Explanation
  • Bounded-Buffer Problem Process
  • Producer Process
  • Consumer Process
  • Application

BOUNDED BUFFER

PROBLEM
Presented By
Vaishnupriya.S
1912034
BOUNDED BUFFER PROBLEM
 Bounded Buffer Problem also called as producer consumer problem
 It is a synchronization problem.
 Producer is producing some items and enters them into the buffer.
 The consumer removes the items from the buffer and consumes them.
 The same memory buffer is shared by both producers and consumers
which is of fixed-size.
 A producer should not produce items into the buffer when the consumer is
consuming an item from the buffer and vice versa. So the buffer should
only be accessed by the producer or consumer at a time.
 Accessing memory buffer should not be allowed to producer and
consumer at the same time.
THE PRODUCER CONSUMER PROBLEM
WITH DIAGRAM
SEMAPHORE
A semaphore S is an integer variable that can be accessed only through two
standard operations

[Link] wait() operation reduces the value of semaphore by 1 .


[Link] signal() operation increases its value by 1.
BOUNDED-BUFFER PROBLEM PROCESS

Shared data:
semaphore full, empty, mutex;

Initialization:
full = 0, empty = n, mutex = 1
PRODUCER PROCESS
do {
produce an item in nextp

wait(empty);
wait(mutex);

add nextp to buffer…
signal(mutex);
signal(full);
} while (1);
CONSUMER PROCESS
do {
wait(full)
wait(mutex);

remove an item from buffer to nextc

signal(mutex);
signal(empty);

consume the item in nextc

} while (1);
APPLICATION

A Pipe or other finite queue (buffer), is an example of the bounded buffer


problem.
THANK YOU

BOUNDED BUFFER 
PROBLEM
Presented By
Vaishnupriya.S
1912034
BOUNDED BUFFER PROBLEM
Bounded Buffer Problem also called as producer consumer problem
It is a synchronization problem.
Pr
A producer should not produce items into the buffer when the consumer is 
consuming an item from the buffer and vice versa.
THE PRODUCER CONSUMER PROBLEM 
WITH DIAGRAM
SEMAPHORE
A semaphore S is an integer variable that can be accessed only through two 
standard operations 
       1.The wait(
BOUNDED-BUFFER PROBLEM PROCESS
Shared data:
semaphore full, empty, mutex;
Initialization:
full = 0, empty = n, mutex = 1
PRODUCER PROCESS
do {
produce an item in nextp
…  
wait(empty);  
wait(mutex);
…
add nextp to buffer… 
 signal(mutex);  
sign
CONSUMER PROCESS
do {  
wait(full)  
wait(mutex);
…
remove an item from buffer to nextc
…
signal(mutex); 
 signal(empty);
…
c
APPLICATION
A Pipe or other finite queue (buffer), is an  example of the bounded buffer 
problem.
THANK YOU

You might also like