Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- binarysem semafor1;
- binarysem semafor2;
- int liczba=0;
- void producent(){
- int i;
- wait(semafor1);
- for(i=0;i<10;i++){
- liczba=random(10);
- }
- signal(semafor2);
- }
- void konsumpcjonista(){
- wait(semafor2);
- cout << liczba << endl;
- signal(semafor1);
- }
- main() {
- int j;
- for(j=0;j<10;j++){
- cobegin {
- initialsem(semafor1,1);
- initialsem(semafor2,0);
- producent();
- konsumpcjonista();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement