linux - Shared Memory and Process Sempahores (IPC) -


this extract advanced liniux programming:


semaphores continue exist after processes using them have terminated. last process use semaphore set must explicitly remove ensure operating system not run out of semaphores.to so, invoke semctl semaphore identifier, number of semaphores in set, ipc_rmid third argument, , union semun value fourth argument (which ignored).the effective user id of calling process must match of semaphore’s allocator (or caller must root). unlike shared memory segments, removing semaphore set causes linux deallocate immediately.


if process allocate shared memory, , many process use , never set delete (with shmctl), if them terminate, shared page continues being available. (we can see ipcs).

if process did shmctl, when last process deattached, system deallocate shared memory.

so far (i guess, if not, correct me).

what dont understand quote did, first say: "semaphores continue exist after processes using them have terminated." , then: "unlike shared memory segments, removing semaphore set causes linux deallocate immediately."

the 2 statements don't contradict each other...

the first statement says semaphore continue exist unless/until program explicitly deletes (i.e. won't auto-deleted when last program stops using it).

the second statement says when program deletes semaphore set, linux deallocate semaphore set (as opposed to, say, waiting other programs stop using first)


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -