Unix IPC primitives

Semaphores

System V semaphores

creation: semget

down and up: semop

other operations: semctl

execute man semget, man semop or man semctl for a description

POSIX semaphores

Two types: named and unnamed semaphores.

Named semaphores.

  • sem_open, sem_close, sem_unlink

  • created in a virtual filesystem (e.g., /dev/sem).

unnamed semaphores – memory based

  • sem_init, sem_destroy

down and up.

  • sem_wait, sem_trywait, sem_timedwait, sem_post

execute man sem_overview for an overview.

Shared memory

Address spaces of processes are independent.

But address spaces are virtual.

The same physical region can be mapped into two or more virtual regions.

This is managed as a resource by the operating system.

System V shared memory

  • creation – shmget

  • mapping and unmapping – shmat, shmdt

  • other operations – shmctl

  • execute man shmget, man shmat man shmdt or man shmctl for a description.

POSIX shared memory

  • creation - shm open, ftruncate

  • mapping and unmapping - mmap, munmap

  • other operations - close, shm unlink, fchmod,...

  • execute man shm_overview for an overview

Last updated