Skip to content

Latest commit

 

History

History
110 lines (101 loc) · 1.81 KB

README.md

File metadata and controls

110 lines (101 loc) · 1.81 KB

SY40-Project

GitHub Workflow Status

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