diff --git a/zadanie.cm b/zadanie.cm new file mode 100644 index 0000000..8eff72e --- /dev/null +++ b/zadanie.cm @@ -0,0 +1,45 @@ +const int N=50; +int buffer[N]; +int write=0; +int read=0; +binarysem sem; + +void add1(){ + int i; + for(i=1;i<=50;i++){ + wait(sem); + buffer[write]=i; + write=(write+1)%N; + signal(sem); + } +} + +void add2(){ + int i=0; + for(i=51;i<=100;i++){ + wait(sem); + buffer[write]=i; + write=(write+1)%N; + signal(sem); + } +} + +void get(){ + int item; + int i; + for(i=0;i<100;i++){ + wait(sem); + item=buffer[read]; + read=(read+1)%N; + cout<