Compare commits
No commits in common. "master" and "master" have entirely different histories.
@ -1,40 +0,0 @@
|
|||||||
monitor prod_kons {
|
|
||||||
int produkt;
|
|
||||||
int nowys;
|
|
||||||
condition nowy, uzyty;
|
|
||||||
void dodaj_element(int pr){
|
|
||||||
if(nowys==1) waitc(uzyty);
|
|
||||||
produkt=pr;
|
|
||||||
nowys=1;
|
|
||||||
signalc(nowy);
|
|
||||||
}
|
|
||||||
int pobierz_element(){
|
|
||||||
if(!nowys) waitc(nowy);
|
|
||||||
nowys=0;
|
|
||||||
signalc(uzyty);
|
|
||||||
return produkt;
|
|
||||||
}
|
|
||||||
init {
|
|
||||||
nowys = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void producent(){
|
|
||||||
int i;
|
|
||||||
for(i=0;i<50;i++){
|
|
||||||
dodaj_element(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void konsument(){
|
|
||||||
int i;
|
|
||||||
for(i=0;i<50;i++){
|
|
||||||
cout << pobierz_element() << endl;;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
main(){
|
|
||||||
cobegin{
|
|
||||||
producent(); konsument();
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user