Skip to content

PiercePickett/OS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

Pierce Pickett Operating Systems Producer Consumer Problem

This is the project that demostrates the use of shared memory and semaphores using C++. This uses two files; producer.cpp and consumer.cpp
While making this program I decided to make a semaphore where the producer puts a random character on the buffer for the consumer to consume. It has come to my attention that the use of the rand() function may affect the output of the program which I would recommend running the program a couple of times in the case the the output isnt exactly:
Produced: A Produced: B Consumed: A Consumed: B

Compiling


To compile the program use a bash terminal with the files in a folder. to get an execution file for the two files use:
g++ producer.cpp -pthread -o producer
g++ consumer.cpp -pthread -o consumcer
Then to run both of the execution files at the same time use:
./producer & ./consumer &

Screenshot 2024-04-04 180523

Screenshot 2024-04-04 180613

About

stuff for OS assignments

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages