Skip to content

Tag: semaphore

C system v Semaphore not locking critical region

I have a code that reads an integer from shared memory and then incerements the number in child processes. I’m using semaphore to lock this critical region so that the integer gets only increased if no other process is not increasing it. So I get a stable integer value. I have used SYSTEM V Semaphore fo…

Handling of blocked named semaphores after a system reboot

Within a Linux Box I’m using named semaphores to control access to system resources used by different processes. If the system accidentally crashes, it can happen, that a semaphore has been acquired but not given back yet. Given that situation, I noticed, that even after a reboot the semaphore remains s…

Semaphores and Mutex behaviour doubts

Do semaphores and mutexes synchronize both threads and processes, or only threads, or only processes? Edit: my mistake it’s C, not shell. Since I programmed through the shell I mistook it. And one more thing: are communication and synchronization the same? Answer SysV IPC semaphores synchronize between …