This project is a simulation of a pizza store implemented in C using pthreads. Each customer order runs as a separate thread, and the program models how orders are handled under limited resources (staff and equipment).
The goal was to practice multithreading, synchronization, and handling shared resources in a realistic scenario.
Each order goes through the following steps:
-
A customer calls the store (telephone operator needed)
-
Payment is processed (there is a small chance it fails)
-
If successful:
- A cook prepares the order
- Ovens are used for baking
- The order is packed
- A deliverer delivers it
All of these steps depend on resource availability, so threads may block and wait.
- 2 telephone operators
- 2 cooks
- 10 ovens
- 10 deliverers
At the end of the simulation, the program prints:
- Total income
- Successful and failed orders
- Number of pizzas per type
- Average and max delivery time
- Average and max cooling time
gcc -o pizza program.c -lpthread
./pizza <customers> <seed>
Example:
./pizza 50 1234
- Randomness is used for order timing, payment success, and delivery time
- Mutexes and condition variables are used to handle shared resources
- The program assumes all time values are in seconds (simulating minutes)
This was part of a project to get more comfortable with:
- pthreads
- synchronization (mutexes / condition variables)
- designing systems where multiple things happen at the same time
- Clean up global variables
- Improve thread-safe random number generation
- Add logging instead of just printing
- Better structure (split into multiple files)
Joanna Papadakaki