timeout semaphore

timeout semaphore

Post by Mark Swaanenbur » Tue, 02 Jul 2002 16:14:33

I want to have my process sleep on a semaphore, but timeout after 10
seconds. I know how to do this with waitqueues:

    current->timeout = 10 * HZ;

or for kernel 2.4

    interruptible_sleep_on_timeout(&somequeue, 10 * HZ);

I am using kernel 2.4.18 so I have worked woth the second version. but a
waitqueue does not seem te be wat I want, so I decided I;m going to use a
semapfore instead, so not everything which is waiting is woken up at the
same time. Now I have searched a book in which
interruptible_sleep_on_timeout(...) was described, but I was not able to
find anything about timing out on a semaphore. so I tried the first variant
of the waitqueue, but replaced the interruptible_sleep_on with
down_interruptible. so it looks like this:

    current->timeout = 10 * HZ;

this does not compile:
    structure has no member named `timeout'

This was also the case when I used this construction for the waitqueue
version. that is the reason I had to search for an alternative and found the
interruptible_sleep_on_timeout function. But I haven't found this for the

does anybody know how I can do this? or is it just obvious and can I just
use something like down_interruptible_timeout(&somesemaphore, timeout)?
(this particular function does not seem to exist, but maybe some variant I
don't know about?)



1. semaphore timeout


Is there a way to specify a time out in msecs, that a semop operation will
last? I.e. I want semop to try for x msecs to get a semaphore, and afterthat
if it wasn;t succesful to exit.


2. HELP! addition in Bourne shell

3. Timeout on semaphores (in kernel context)

4. kde 981022 snapshots configure issues

5. 2.5.49 - semaphore operations with timeouts

6. Newbie question

7. timeout a semaphore

8. Novell Netware requester

9. timeout on semaphore

10. : Semaphore with Timeout?

11. timeout requirement for semaphores

12. timeout a semaphore

13. Need a Posix semaphore timeout system