Go to the source code of this file.
Defines | |
| #define | CF_LOCK_SEM 0 |
| #define | CF_READER_SEM 1 |
| #define | CF_WRITER_SEM 2 |
Functions | |
| int | shm_lock_exclusive (int semid) |
| Try to lock a shared memory segment exclusive. | |
| int | shm_unlock_exclusive (int semid) |
| Unlock an exclusive lock. | |
| int | shm_lock_shared (int semid) |
| Try to lock a shared memory segment shared. | |
| int | shm_unlock_shared (int semid) |
| Try to unlock a shared lock. | |
Definition in file shm_locking.h.
|
|
The semaphore locking semaphore number Definition at line 27 of file shm_locking.h. |
|
|
The reader locking semaphore number Definition at line 28 of file shm_locking.h. |
|
|
The writer locking semaphore number Definition at line 29 of file shm_locking.h. |
|
|
Try to lock a shared memory segment exclusive. We want to lock the shared memory segment exclusively (e.g. for write access). Therefore we have to set the exclusive-bit and we have to wait until the shared counter is 0. The semaphore has to be locked during the exclusive operations, so we *DON'T* unlock it in this routine! Definition at line 41 of file shm_locking.c. |
|
|
Try to lock a shared memory segment shared. We can lock a shared memory segment shared if the exclusive bit is not set and the semaphore is not locked. The shared lock itself is just a incrementation of the shared counter. The semaphore will be unlocked at the end of this routine, but the shared counter has to be decremented, too. Definition at line 75 of file shm_locking.c. |
|
|
Unlock an exclusive lock. We release an exclusive lock by setting the value of the writer-semaphore to 0. Definition at line 63 of file shm_locking.c. |
|
|
Try to unlock a shared lock. We release the shared lock by decrementing the shared counter. Definition at line 84 of file shm_locking.c. |
1.3.5