30 lines
306 B
Plaintext
30 lines
306 B
Plaintext
semaphore s;
|
|
semaphore t;
|
|
int liczba;
|
|
|
|
void kons(){
|
|
int i;
|
|
for(i=0; i<10; i=i+1){
|
|
wait(t);
|
|
cout << liczba << endl;
|
|
signal(s);
|
|
}
|
|
}
|
|
|
|
void prod(){
|
|
int i;
|
|
for(i=0; i<10; i=i+1){
|
|
wait(s);
|
|
liczba=i;
|
|
signal(t);
|
|
}
|
|
}
|
|
|
|
main(){
|
|
initialsem(s, 1);
|
|
initialsem(t, 0);
|
|
cobegin{
|
|
prod(); kons();
|
|
}
|
|
}
|