Re: deadlock avoidance?

Johannes Erdfelt (jerdfelt@sventech.com)
Wed, 8 Dec 1999 14:20:20 -0500


On Wed, Dec 08, 1999, Davide Libenzi <dlibenzi@maticad.it> wrote:
> Wednesday, December 08, 1999 5:39 PM
> Johannes Erdfelt <jerdfelt@sventech.com> wrote :
> > Process A on CPU #0 acquires lock->lock and then goes to set the
> > lock->pid. Process B on CPU #1 then simultaneously dereferences
> > lock->pid.
> >
> > AFAIK you can't guarantee than CPU #0 writes lock->pid correctly before
> > CPU #1 tries to read it.
> >
> > Basically there's no locking/atmomicity of lock->pid.
>
> What's the problem if CPU1 read pid == 0 before CPU0 set pid = CPU0.pid ?
> CPU1 goto acquire the lock and spin !
> The same behaviour will appen even if CPU1 read the lock->pid after his
> value became CPU0.pid.
> It will go to get the lock and spin.

What if only a portion of the 16 bit number has been written before it
is read? IIRC there are some architectures which this could possibly
happen on.

JE

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