Pliki_SOP/Zadania_domowe/test2/zad3.cm
Jakub Adamski 807c890ac7 Test
2018-12-10 12:01:06 +01:00

30 lines
576 B
Plaintext

monitor s{
condition c;
condition t;
int result;
int computed;
void complicatedCalculation(){
result = 42;
computed = 1;
signalc(c);
signalc(t);
}
int askAboutUniverse(){
if (computed != 1){ waitc(t); }
return result;
}
int getPizzaDiameter(){
if (computed != 1){ waitc(c); }
return result;
}
init { result = 0; computed = 0; }
}
void server() { complicatedCalculation(); }
void scientist() { cout << askAboutUniverse() << endl; }
void pizzerman() { cout << getPizzaDiameter() << endl; }
main(){
cobegin { server(); scientist(); pizzerman(); }
}