Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <sys/ipc.h>
- #include <sys/shm.h>
- #include <sys/sem.h>
- #include <signal.h>
- #define PERMS 0666
- static struct sembuf op_lock1[1] = {0, -1, 0};
- static struct sembuf op_unlock1[1] = {0, 1, 0};
- static struct sembuf op_lock2[1] = {1, -1, 0};
- static struct sembuf op_unlock2[1] = {1, 1, 0};
- void blokuj_semafor1(int semid){
- if (semop(semid, &op_lock1[0], 1)<0)
- perror("blad blokowania semafora");
- }
- void odblokuj_semafor1(int semid){
- if (semop(semid, &op_unlock1[0], 1) < 0)
- perror("blad odlokowania semafora");
- }
- void blokuj_semafor2(int semid){
- if (semop(semid, &op_lock2[0], 1)<0)
- perror("blad blokowania semafora");
- }
- void odblokuj_semafor2(int semid){
- if (semop(semid, &op_unlock2[0], 1) < 0)
- perror("blad odlokowania semafora");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement