* timing out on a semaphore
@ 2001-02-25 22:40 Tim Waugh
2001-02-25 22:53 ` Davide Libenzi
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Tim Waugh @ 2001-02-25 22:40 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 452 bytes --]
I'm trying to chase down a semaphore time-out problem. I want to
sleep on a semaphore until either
(a) it's signalled, or
(b) some amount of time has elapsed.
What I'm doing is calling add_timer, and then down_interruptible, and
finally del_timer. The timer's function ups the semaphore.
The code is in parport_wait_event, in drivers/parport/ieee1284.c.
Can anyone see anything obviously wrong with it? It seems to
sometimes get stuck.
Tim.
*/
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: timing out on a semaphore
2001-02-25 22:40 timing out on a semaphore Tim Waugh
@ 2001-02-25 22:53 ` Davide Libenzi
2001-02-25 23:10 ` Andrew Morton
2001-02-26 9:19 ` Arjan van de Ven
2 siblings, 0 replies; 8+ messages in thread
From: Davide Libenzi @ 2001-02-25 22:53 UTC (permalink / raw)
To: Tim Waugh; +Cc: linux-kernel
On 25-Feb-2001 Tim Waugh wrote:
> I'm trying to chase down a semaphore time-out problem. I want to
> sleep on a semaphore until either
>
> (a) it's signalled, or
> (b) some amount of time has elapsed.
>
> What I'm doing is calling add_timer, and then down_interruptible, and
> finally del_timer. The timer's function ups the semaphore.
>
> The code is in parport_wait_event, in drivers/parport/ieee1284.c.
>
> Can anyone see anything obviously wrong with it? It seems to
> sometimes get stuck.
If it's SMP, have You tried to call del_timer_sync() ?
- Davide
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: timing out on a semaphore
2001-02-25 22:40 timing out on a semaphore Tim Waugh
2001-02-25 22:53 ` Davide Libenzi
@ 2001-02-25 23:10 ` Andrew Morton
2001-02-27 14:39 ` Tim Waugh
2001-02-26 9:19 ` Arjan van de Ven
2 siblings, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2001-02-25 23:10 UTC (permalink / raw)
To: Tim Waugh; +Cc: linux-kernel
Tim Waugh wrote:
>
> I'm trying to chase down a semaphore time-out problem. I want to
> sleep on a semaphore until either
>
> (a) it's signalled, or
> (b) some amount of time has elapsed.
>
> What I'm doing is calling add_timer, and then down_interruptible, and
> finally del_timer. The timer's function ups the semaphore.
>
> The code is in parport_wait_event, in drivers/parport/ieee1284.c.
>
> Can anyone see anything obviously wrong with it? It seems to
> sometimes get stuck.
I think there might be a bogon in __down_interruptible's
handling of the semaphore state in this case. I remember
spotting something a few months back but I can't immediately
remember what it was :(
I'd suggest you slot a
sema_init(&port->physport->ieee1284.irq, 1);
into parport_wait_event() prior to adding the timer. If that
fixes it I'll go back through my patchpile, see if I can
resurrect that grey cell.
-
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: timing out on a semaphore
2001-02-25 22:40 timing out on a semaphore Tim Waugh
2001-02-25 22:53 ` Davide Libenzi
2001-02-25 23:10 ` Andrew Morton
@ 2001-02-26 9:19 ` Arjan van de Ven
2 siblings, 0 replies; 8+ messages in thread
From: Arjan van de Ven @ 2001-02-26 9:19 UTC (permalink / raw)
To: Tim Waugh; +Cc: linux-kernel
In article <20010225224039.W13721@redhat.com> you wrote:
> --2F7AbV2suvT8PGoH
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> I'm trying to chase down a semaphore time-out problem. I want to
> sleep on a semaphore until either
> (a) it's signalled, or
> (b) some amount of time has elapsed.
> What I'm doing is calling add_timer, and then down_interruptible, and
> finally del_timer. The timer's function ups the semaphore.
What we _really_ need is down_timeout(), which I plan to implement for early
2.5. The semantics should by similar to the try_lock functions, exect that
it will try for a specified amount of time first.
Greetings,
Arjan van de Ven
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: timing out on a semaphore
2001-02-25 23:10 ` Andrew Morton
@ 2001-02-27 14:39 ` Tim Waugh
2001-02-27 22:40 ` Andrew Morton
0 siblings, 1 reply; 8+ messages in thread
From: Tim Waugh @ 2001-02-27 14:39 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 668 bytes --]
On Sun, Feb 25, 2001 at 11:10:39PM +0000, Andrew Morton wrote:
> I think there might be a bogon in __down_interruptible's
> handling of the semaphore state in this case. I remember
> spotting something a few months back but I can't immediately
> remember what it was :(
>
> I'd suggest you slot a
>
> sema_init(&port->physport->ieee1284.irq, 1);
>
> into parport_wait_event() prior to adding the timer. If that
> fixes it I'll go back through my patchpile, see if I can
> resurrect that grey cell.
I haven't been able to confirm that it works around it (can't repeat
the problem here), but what would you say if I said it did? ;-)
Tim.
*/
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: timing out on a semaphore
2001-02-27 14:39 ` Tim Waugh
@ 2001-02-27 22:40 ` Andrew Morton
2001-02-27 23:28 ` Tim Waugh
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2001-02-27 22:40 UTC (permalink / raw)
To: Tim Waugh; +Cc: linux-kernel
Tim Waugh wrote:
>
> On Sun, Feb 25, 2001 at 11:10:39PM +0000, Andrew Morton wrote:
>
> > I think there might be a bogon in __down_interruptible's
> > handling of the semaphore state in this case. I remember
> > spotting something a few months back but I can't immediately
> > remember what it was :(
> >
> > I'd suggest you slot a
> >
> > sema_init(&port->physport->ieee1284.irq, 1);
> >
> > into parport_wait_event() prior to adding the timer. If that
> > fixes it I'll go back through my patchpile, see if I can
> > resurrect that grey cell.
>
> I haven't been able to confirm that it works around it (can't repeat
> the problem here), but what would you say if I said it did? ;-)
One of two things:
1: Your code is leaving the semaphore in a down'ed state
somehow.
2: The semaphore code is leaving the semaphore in a funny
state.
hmm. I see from your other email that the sema_init() has
made the problem go away. Could you please review the code,
see if there's an imbalance somewhere?
What is parport_ieee1284_write_compat() trying to do with
the semaphore? It will leave the semaphore in a downed
state. Intentional? Is this code actually being used
by the person who is having the problem? Could this
loop be replaced by a simple sema_init()?
(As you can tell, I'm desparately avoiding having
to understand the semaphore code again :))
-
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: timing out on a semaphore
2001-02-27 22:40 ` Andrew Morton
@ 2001-02-27 23:28 ` Tim Waugh
2001-02-27 23:35 ` Davide Libenzi
0 siblings, 1 reply; 8+ messages in thread
From: Tim Waugh @ 2001-02-27 23:28 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 344 bytes --]
On Tue, Feb 27, 2001 at 10:40:35PM +0000, Andrew Morton wrote:
> 1: Your code is leaving the semaphore in a down'ed state
> somehow.
This was probably it. I don't know why it works for me but not some
other people though. :-/
> (As you can tell, I'm desparately avoiding having
> to understand the semaphore code again :))
:-)
Tim.
*/
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: timing out on a semaphore
2001-02-27 23:28 ` Tim Waugh
@ 2001-02-27 23:35 ` Davide Libenzi
0 siblings, 0 replies; 8+ messages in thread
From: Davide Libenzi @ 2001-02-27 23:35 UTC (permalink / raw)
To: Tim Waugh; +Cc: linux-kernel, Andrew Morton
On 27-Feb-2001 Tim Waugh wrote:
> On Tue, Feb 27, 2001 at 10:40:35PM +0000, Andrew Morton wrote:
>
>> 1: Your code is leaving the semaphore in a down'ed state
>> somehow.
>
> This was probably it. I don't know why it works for me but not some
> other people though. :-/
UP vs. MP ?
- Davide
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2001-02-27 23:34 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-25 22:40 timing out on a semaphore Tim Waugh
2001-02-25 22:53 ` Davide Libenzi
2001-02-25 23:10 ` Andrew Morton
2001-02-27 14:39 ` Tim Waugh
2001-02-27 22:40 ` Andrew Morton
2001-02-27 23:28 ` Tim Waugh
2001-02-27 23:35 ` Davide Libenzi
2001-02-26 9:19 ` Arjan van de Ven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).