Re: deadlock avoidance?

Davide Libenzi (dlibenzi@maticad.it)
Wed, 8 Dec 1999 20:13:22 +0100


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.

Cheers,
Davide.

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