Pliki_SOP/Zadania_domowe/zajecia6/prod-cons.lst
2018-12-05 17:53:14 +01:00

33 lines
747 B
Plaintext

BACI System: C-- to PCODE Compiler in C, 11:30 1 Oct 2012
Source file: prod-cons.cm Tue Dec 4 15:01:25 2018
line pc
1 0 semaphore s;
2 0 semaphore t;
3 0 int liczba;
4 0
5 0 void kons(){
6 0 int i;
7 0 for(i=0; i<10; i=i+1){
8 14 wait(t);
9 16 cout << liczba << endl;
10 19 signal(s);
11 21 }
12 22 }
13 23
14 23 void prod(){
15 23 int i;
16 23 for(i=0; i<10; i=i+1){
17 37 wait(s);
18 39 liczba=i;
19 42 signal(t);
20 44 }
21 45 }
22 46
23 46 main(){
24 47 initialsem(s, 1);
25 50 initialsem(t, 0);
26 53 cobegin{
27 54 prod(); kons();
28 60 }
29 61 }