Re: mutex lock function pair?

Alan Cox (alan@lxorguk.ukuu.org.uk)
Fri, 10 Sep 1999 01:00:06 +0100 (BST)


> When 1st thread call mutex lock, it acquired lock and process the followed
> code. If other threads try to acquire same lock before the lock is
> released, those threads are put into sleep. When 1st thread finished
> process and releases lock through mutex unlock, all other sleeping threads
> which are waiting for the lock are waken and try to acquire the lock.
> Whoever gets the lock can be processed and others go back to sleep again.
> Those mutex lock/unlock pair provide protection for critical pass.

The Linux semaphores provide mutex locking. The calls being

down(&sem)
up(&sem)

and also

down_interruptible(&sem)

which allows for signals to interrupt .. ie

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/