Skip to content

azeemhusain811/Producer-Consumer-Problem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Producer-Consumer Problem

Operating System Project (4th Semester)

The Producer-Counsumer Problem may seem to be similar to Reader-Writer Problem but it not so, both the examples of multi-process synchronization problem and about resource sharing.

Problem

To make sure that the producer won't try to append the data into buffer if it is full and that the consumer won't try to remove data from an empty buffer. Producer can't produce data when consumer is consuming and vice-versa.

Solution

The producer is to either go to sleep or discard data if the buffer is full. The next time the consumer removes an item from the buffer, it notifies the producer, who starts to fill the buffer again. In the same way, the consumer can go to sleep if it finds the buffer to be empty. The next time the producer puts data into the buffer, it wakes up the sleeping consumer. An inadequate solution could result in a deadlock where both processes are waiting to be awakened.

About

Operating System Project (4th Semester)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages