public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
From: Gottlob Frege <gottlobfrege@gmail.com>
To: Ross Johnson <RossJohnson@homemail.com.au>
Cc: Pthreads-Win32 list <pthreads-win32@sources.redhat.com>
Subject: Re: New pthreads-w32 releases available: versions 2.3.0 and 1.7.0
Date: Wed, 13 Apr 2005 08:21:00 -0000	[thread overview]
Message-ID: <97ffb31050413012126fe8ae0@mail.gmail.com> (raw)
In-Reply-To: <1113378289.9335.83.camel@desk.home>

On 4/13/05, Ross Johnson <RossJohnson@homemail.com.au> wrote:
> [...]
> So I'm now hoping that someone might take a look and point out the error
> and also, that the error is retrievable
> [...]

Yeah, I still have 'take another crack at call_once' on my list of things to do.


If we end up needing to mess with thread priorities anyhow (although
only in the cancel case), it might be easiest to just boost everyone's
priority right away, which was my first version (Alex might remember
seeing it on comp.programming.threads).  Something like (from memory,
and with interlocks, etc, left out):


oldpriority = GetPriority();
SetPriority(MAX); // must do this before checking initted - otherwise
could be too late!

if (!started++)
{
   do_init();
   initted = true;
}
else
{
     SetPriority(oldPriority); // note that oldPriority may
coincidentally be MAX
     while( !initted)
     {
          Sleep(1);
     }
}


Very much like the old original version, but since we mess with the
priorities, we don't have to worry about starvation  (even the worse
case where a waiter's original priority is MAX, the init still gets a
share of time (assuming a reasonable scheduler))

From this version, adding cancellation / exception handling should be easy.

But I never liked this version much:
   - not sure of the overhead of SetPriority
   - not sure of portability  (stuff like this is inherently not very
portable, and pthreads-win32 obviously doesn't care, but I care for my
purposes)
   - just 'inelegant' (polling, etc...)

  reply	other threads:[~2005-04-13  8:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-12  7:46 Ross Johnson
2005-04-12 10:10 ` Alexander Terekhov
2005-04-13  7:45   ` Ross Johnson
2005-04-13  8:21     ` Gottlob Frege [this message]
2005-04-14 16:19     ` Alexander Terekhov
2005-04-15  3:08       ` Ross Johnson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=97ffb31050413012126fe8ae0@mail.gmail.com \
    --to=gottlobfrege@gmail.com \
    --cc=RossJohnson@homemail.com.au \
    --cc=pthreads-win32@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).