Pliki_SOP/zajecia6/zad2.cm

20 lines
240 B
Plaintext
Raw Normal View History

2018-12-05 18:09:07 +01:00
binarysem s;
int suma=0;
void dodawanie (int ile){
int i;
for(i=0; i<ile; i=i+1){
wait(s);
suma=suma+1;
signal(s);
}
}
main(){
initialsem(s, 1);
cobegin{
dodawanie(10); dodawanie(10);
}
cout << "Suma = " << suma << endl;
}