Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Operating Systems

Code within repository is for Kent State Operating Systems project 1.

Overview

This project attempts to implement the producer consumer relationship in the shared memory utilizing a buffer.
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

Semaphores are used to synchronize producer and consumer.
Mutual exclusion is considered.
We use threads in the producer program and consumer program.
Shared memory is used for the “table”.

There are two programs one for the producer and one for the consumer.

Compilation

To compile the program two steps are nessesary. Clone the respository and run the following:

$ g++ producer.cpp -pthread  -o producer
$ g++ consumer.cpp -pthread  -o consumer
./producer & ./consumer

Output expectation will appear different each time and the values added to the table are randomly generated numbers of values 1 through 10.
But the following is an example:

Producer produced data: 5
Producer produced data: 6
Consumer is consuming data: 5
Consumer is consuming data: 6

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages