This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] pthread_fork Part 3


On Fri, 2002-09-20 at 23:06, Thomas Pfaff wrote:

> If you want to work around this you must use a mutex to protect the entire
> list.

Or: don't delete foo; the keys, instead foo->deleteme();

pthread_key::pthread_key(){
  inuse_count = 1;
}

pthread_key::deleteme() {
  interlockedincrement(inuse_count)
  if interlockeddecrement (inuse_count) == 0
    delete this;
}


pthread_key::rundestructor() {
if (interlockeddecrement(inuse_count) == 0)
  delete this
}

This prevents the race you describe with no locks.

Still, this race is actually one ieee says we don't care about IIRC,
it's up to the user to synchronise calls like this.
Rob

Attachment: signature.asc
Description: This is a digitally signed message part


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]