https://github.com/axel7083/sy40-project
Small school project. Using either semaphore/processus or monitors/threads to synchronized elements.
https://github.com/axel7083/sy40-project
monitors processus semaphores threads
Last synced: 11 months ago
JSON representation
Small school project. Using either semaphore/processus or monitors/threads to synchronized elements.
- Host: GitHub
- URL: https://github.com/axel7083/sy40-project
- Owner: axel7083
- Created: 2020-12-29T03:04:16.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-08T08:02:57.000Z (over 5 years ago)
- Last Synced: 2025-07-19T20:42:00.941Z (11 months ago)
- Topics: monitors, processus, semaphores, threads
- Language: C
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SY40-Project

The goal of this program is to `simulate` the behaviour of a jam factory. We split the problem in 4 separated elements which must be synchronized.
- The small jar injector
- The big jar injector
- The valve
- The clock
We need to make the same exercise using two separate sets of tools
- Processus and semaphores
- Threads and monitors
For both we can write a solution (pseudo-code) considering we have a function P(int i) which is called by a processus/threads waiting for another processus/threads to call V(int i).
## Pseudo-code
Jar Function
Valve Function
Clock Function
Jar_2 Function
Start
While True Then
Insert_Jar()
V(1)
P(0)
Remove_Jar()
V(3)
P(3)
End While
End
Start
While True Then
P(1)
Open_Valve()
V(2)
P(2)
Close_Valve()
V(0)
End While
End
Start
While True Then
P(2)
Sleep(30)
V(2)
End While
End
Start
While True Then
P(3)
Insert_Jar()
For i from 0 to 2
V(1)
P(0)
Remove_Jar()
V(3)
End While
End
## Usage
```
Usage ./main
-t , run the demo using threads and monitors. (Default use semaphores and processus)
-v, --verbose , explain what is being done
-g1 [VALUE] , number of small jar to produce (Default 1)
-g2 [VALUE] , number of big jar to produce (Default 1)
-h, --help , display this help and exit
--version , output version information and exit
```
## Build from source
This project is using Make to build. Run `make -f makefile [OPTION]`.
Options are:
- Clean
- Run