Semaphore

Dave Hylands dhylands at gmail.com
Tue Feb 21 11:14:08 EST 2012


Hi Santosh,

On Tue, Feb 21, 2012 at 5:47 AM, SaNtosh kuLkarni
<santosh.yesoptus at gmail.com> wrote:
> A certain  kernel process has acquired a semaphore lock and meanwhile during
> this period the process gets killed abruptly (and it has not released the
> sem lock..//.sem down).....and the other processes cannot acquire the lock,
> what can be done in this case.

Normally, the semaphore would be associated with a driver of some
type. If the process opened the driver, then regardless of how the
process dies, the file that was opened by the process will eventually
be closed by the kernel and the driver's release function will get
called. This gives you the opportunity to release the semaphore. The
driver would be responsible for tracking the state of the semaphore.
Fundamentally the driver is responsible for cleaning up all of the
resources that it may be using, and a semaphore is just another
resource, like memory.

I'm assuming that the semaphore is one which is held across multiple
calls into the kernel, otherwise you don't have an issue in the first
place, unless there is a bug on the kernel side of things which
actually caused the process to terminate.

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com



More information about the Kernelnewbies mailing list