Skip to content

Latest commit

 

History

History
7 lines (6 loc) · 690 Bytes

README.md

File metadata and controls

7 lines (6 loc) · 690 Bytes

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)]