Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. int create_semaphor(union semun ctl, char letter){
  2.     key_t key;                          //klucze semaforów
  3.     int semid;
  4.  
  5.     if ((key = ftok(".", letter)) == -1)
  6.         errx(1, "Blad tworzenia klucza!");
  7.  
  8.     if ((semid = semget(key, 1, IPC_CREAT | 0600)) == -1)
  9.         errx(2, "Blad tworzenia semafora!");
  10.  
  11.     ctl.val = 1;
  12.     if (semctl(semid, 0, SETVAL, ctl) == -1)
  13.         errx(3, "Blad ustawiania semafora!");
  14.  
  15.     return semid;
  16. }
  17.  
  18.  
  19.  
  20.  
  21.     semid0 = create_semaphor(ctl, 'a');                        
  22.     semid1 = create_semaphor(ctl, 'b');                      
  23.     semid2 = create_semaphor(ctl, 'g');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement