Re: deadlock avoidance?

Johannes Erdfelt (jerdfelt@sventech.com)
Tue, 7 Dec 1999 19:32:10 -0500


On Wed, Dec 08, 1999, Davide Libenzi <dlibenzi@maticad.it> wrote:
> Wednesday, December 08, 1999 1:05 AM
> Alan Cox <alan@lxorguk.ukuu.org.uk> wrote :
> > > See at this implementation ( optimization = 0.0 ) :
> > Correctness ditto 8)
> >
> > > ++lock->count; \
> >
> > These need to use atomic operations - dec and not zero etc
> >
>
> Hi Alan,
>
> ++lock->count;
>
> is executed only "if (lock->pid == getpid())" == the task already own
> the lock.

Wouldn't lock->pid need to be atomic?

On x86 this shouldn't be an issue since atomic_read has no magic but on
other architectures, lock->pid setting and reading may race.

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/