lkml.org 
[lkml]   [1999]   [Oct]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: How to create kernel semaphore that will timeout?
From
Date
Matthew.Wilcox@genedata.com (Matthew Wilcox) writes:

> On Mon, Oct 11, 1999 at 04:00:50PM -0500, Bret Indrelee wrote:
> > What is the best way to create a kernel semaphore that will time out after
> > so many clock ticks?
> >
> > The normal kernel semaphore code doesn't provide a timeout value, if you
> > wait it is assumed to be OK to wait forever.
> >
> > One of the things I would like to do with such a semaphore is to implement a
> > timeout on DMA transfers, such that if the transfer doesn't complete in so
> > much time it will give up. I would also like to implement some simple device
> > locking using it.
>
> Why not just use a timer which unlocks the semaphore after a given period?

You can unlock a semaphore which you're holding, but there is no clean
to cancel a pending semaphore down request, which would be required for
down_trylock_timeout().

Workaround: use a wait queue and schedule_timeout.

-Andi

--
This is like TV. I don't like TV.

-
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/

\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.042 / U:0.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site