[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Pthreads-hackers] pthreads and cancellation
From: |
Marcus Brinkmann |
Subject: |
Re: [Pthreads-hackers] pthreads and cancellation |
Date: |
Sat, 26 Jan 2002 18:49:54 +0100 |
User-agent: |
Mutt/1.3.25i |
On Sat, Jan 26, 2002 at 05:08:09PM +0100, Marcus Brinkmann wrote:
> A condition becomes not a struct, but a pointer to a struct.
Small correction, to avoid race conditions, this must be a struct that
contains a spin lock and a pointer to another struct, containing the rest
of the structure. It's unfortunate that just to support statically
initialized condition variables, we have to acquire two spin locks to get at
the condition variable. But it can not be helped (well, it could be helped
by an atomic int or pointer variable that signals the initialization
status, so you would only need to get that lock if it is not yet
initialized, and re-check the initialization status, as the status is not
changed afterwards. Unfortunately I don't think we have atomic ints
generally available, do we?).
Interestingly, the bsd implementation does not check this. They have a race
here, where they could leak memory, or possibly even get wrong results [dead
locks etc] if a statically initialized condition variable is accessed the
first time in two threads concurrently.
Thanks,
Marcus
--
`Rhubarb is no Egyptian god.' Debian http://www.debian.org address@hidden
Marcus Brinkmann GNU http://www.gnu.org address@hidden
address@hidden
http://www.marcus-brinkmann.de