File was renamed from squeue/pcsem.c |
| | |
| | | #include "pcsem.h" |
| | | #include "sem_util.h" |
| | | |
| | | |
| | | int pcsem::init(key_t key, unsigned int value) { |
| | | int SemUtil::get(key_t key, unsigned int value) { |
| | | int semid, perms; |
| | | |
| | | perms = S_IRUSR | S_IWUSR; |
| | |
| | | set to EINTR if operation was interrupted by a signal handler */ |
| | | |
| | | /* Reserve semaphore - decrement it by 1 */ |
| | | int pcsem::dec(int semId) |
| | | int SemUtil::dec(int semId) |
| | | { |
| | | struct sembuf sops; |
| | | |
| | |
| | | return 0; |
| | | } |
| | | |
| | | int pcsem::dec_nowait(int semId) |
| | | int SemUtil::dec_nowait(int semId) |
| | | { |
| | | struct sembuf sops; |
| | | |
| | |
| | | return 0; |
| | | } |
| | | |
| | | int pcsem::dec_timeout(int semId, struct timespec * timeout) |
| | | int SemUtil::dec_timeout(int semId, struct timespec * timeout) |
| | | { |
| | | struct sembuf sops; |
| | | |
| | |
| | | |
| | | |
| | | /* Release semaphore - increment it by 1 */ |
| | | int pcsem::inc(int semId) |
| | | int SemUtil::inc(int semId) |
| | | { |
| | | struct sembuf sops; |
| | | |
| | |
| | | return semop(semId, &sops, 1); |
| | | } |
| | | |
| | | void pcsem::remove(int semid) { |
| | | void SemUtil::remove(int semid) { |
| | | union semun dummy; |
| | | if (semctl(semid, 0, IPC_RMID, dummy) == -1) |
| | | err_exit(errno, "semctl"); |