Skip to content

Create a semaphore-based solution to the producer-consumer problem

License

Notifications You must be signed in to change notification settings

njeunje/Producer-Consumer-Problem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Producer-Consumer Problem

Create a semaphore-based solution to the producer-consumer problem

prod_cons_JonathanNjeunje

prod_cons_JonathanNjeunje is a C program designed to do an simulate the producer-consumer problem solution with semaphore and mutex lock to protect their critical sections.

Installatoion

Use the commande below to compile the .c file.

gcc -o prod_cons_JonathanNjeunje prod_cons_JonathanNjeunje.c -lpthread -lrt

Usage

Run the command below to execute the program. Note that the program offers the following tweaks to vary the simulation.

  • A "DEBUG" (boolean) constant [defualt value: true] to activate/deactivate debug lines. This lines shows the entrance/exit of each producer and consummer to/from their respective critical sections.

  • A "PROD_SPEED" (int) constant in microseconds [default value: 1s] to simulate a given production speed.

  • A "CONS_SPEED" (int) constant in microseconds [default value: 4s] to simulate a given consumption speed.

Note: after changing any of these parameters in the source code (c file) make sure to recompile before rexecuting the program with the underneath command.

./prod_cons_JonathanNjeunje

Contributing

Any Contributions are welcome.

##Authors and acknowledgment Jonathan Njeunje

##Licence MIT

About

Create a semaphore-based solution to the producer-consumer problem

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages