producer-consumer problem
This project implements the Producer-Consumer problem with POSIX threads, shared memory, mutex locks, and conditions for both of the producer and consumer processes' critical section.
Files: <consumer.cpp> - Consumer process <producer.cpp> - Producer process <shared_buffer.h> - Shared memory
- Basic I/0 operations - Standard queue data structure, FIFO and buffer management <pthread.h> - POSIX threading, pthread() functions, memory synchronization/execution <unistd.h> - POSIX operating system API, sleep()
g++ producer.cpp -o producer -pthread
g++ consumer.cpp -o consumer -pthread
./producer & ./consumer &
To kill all processes after running the program with ./producer & ./consumer &
,
run the UNIX terminal command: killall producer; killall consumer