Skip to content

Solution of the producer-consumer problem in C using POSIX semaphores

Notifications You must be signed in to change notification settings

Matie26/shared-buffer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Solution of the producer-consumer problem in C using POSIX semaphores

This code is an implementation of shared buffer that can work in both modes: LIFO / FIFO.

Shared memory problem, writing to full buffer and reading from empty buffer are solved by using 3 POSIX semaphores: mutex, empty and full. In order to test this solution, 5 producers and 5 consumers are created and their task is to write/read given amount of data to/from the same buffer. When all of them finish, data read by consumers is written to new buffer (this time they act as producers) which is later checked for any duplicates.

Usage:

./sharedBuffer [buffer_size] [buffer_mode (0:LIFO 1:FIFO)]

About

Solution of the producer-consumer problem in C using POSIX semaphores

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published