Skip to content

SophyMatar/Producer_Comsumer_Problem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Producer Comsumer Problem

The producer generates items and puts items onto the table. The consumer will pick up items. The table can only hold two items at the same time. When the table is complete, the producer will wait. When there are no items, the consumer will wait. We use semaphores to synchronize producer and consumer. Mutual exclusion should be considered. We use threads in the producer program and consumer program. Shared memory is used for the “table”.

To compile the programs:

$ g++ producer.cpp -pthread -lrt -o producer

$ g++ consumer.cpp -pthread -lrt -o consumer

$ ./producer & ./consumer &

#Example

Screen Shot 2022-11-01 at 11 58 26 PM

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages