Re: race condition in down_interruptible

Andrea Arcangeli (andrea@e-mind.com)
Sat, 13 Feb 1999 18:10:25 +0100 (CET)


On Sat, 13 Feb 1999, Ulrich Schmid wrote:

>> > sem->count sem->waking
>> >No process holds the semaphore 1 0
>> >Process A acquires the semaphore 0 0
>> >Process B calls down_interruptible() -1 0
>> >Process B is interrupted and passes
>> > waking_non_zero() -1 0
>> >Process A calls up() (on another CPU) 0 1
>>
>> B get wakenup and runs waking_non_zero that sees sem->waking == 1 and so
>> do sem->waking-- and then B has no way to runs atomic_inc() because
>> waking_non_zero returned 1 (owned the semaphore).
>
>If B runs waking_non_zero before A calls up, it will see sem->waking == 0.

So? If B runs waking_non_zero (called by __down_interruptible()) at the
time sem->waking is 0, it will go to sleep in schedule() and will do
nothing.

If insted __down_interruptible() will se a signal pending it will simply
undo the decl() done inside __inline__ down().

Can you explain better your point?

Andrea Arcangeli

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