29 lines
285 B
Plaintext
29 lines
285 B
Plaintext
semaphore se;
|
|
int liczba1=0;
|
|
int liczba2=0;
|
|
int s=0;
|
|
|
|
void suma(){
|
|
wait(se);
|
|
wait(se);
|
|
s=liczba1+liczba2;
|
|
}
|
|
|
|
void a(){
|
|
liczba1=10;
|
|
signal(se);
|
|
}
|
|
|
|
void b(){
|
|
liczba2=5;
|
|
signal(se);
|
|
}
|
|
|
|
main(){
|
|
initialsem(se, 0);
|
|
cobegin{
|
|
a(); b(); suma();
|
|
}
|
|
cout << "Suma = " << s << endl;
|
|
}
|