Unnamed Semaphore in Linux User space

As the name suggests, the semaphore does not have a name in the Linux File system. These semaphores are also called as memory-based semaphores. since, the semaphore does not have a name associated with it in the Linux File system, the semaphore needs to be placed in a shared memory region that different processes or threads share.

the “sem_init” function initializes the semaphore. It also informs whether the semaphore will be shared between processes or threads of a single process.

FIG Courtesy: Linux Programming Interface
  1. pshared – if value is 0 – semaphore is shared between threads of same parent process. If non-zero – semaphore is shared between processes. The semaphore in such a scenario needs to be created in a shared memory region.
  2. value – initial value of the semaphore
FIG Courtesy: Linux Programming Interface

The sem_post and sem_wait functions can be used to release and obtain a semaphore.

Fig Courtesy: Linux Programming Interface

Linux 802.11 SoftMAC architecture

Comments

  1. Pingback: Named Semaphore in Linux user space | Hitch Hiker's Guide to Learning

Leave a Reply

Your email address will not be published. Required fields are marked *