This is the mail archive of the pthreads-win32@sources.redhat.com mailing list for the pthreas-win32 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: starvation in pthread_once?


Do you think it is worth avoiding the named_mutex in favor of a event
only created on contention (my version)? (I do, obviously).

I'm guessing that for typical usage, contention will be low.  And, in
my own code, I'm considering making statically initialized mutexes (or
CSes) by using a call_once in their constructor.  It would just seem
like overkill if all my mutexes needed a mutex to init themselves.


On Tue, 8 Mar 2005 10:58:23 +0100, Alexander Terekhov
<TEREKHOV@de.ibm.com> wrote:
> 
> Grrr. Bad day.
> 
>  if (!once_control) {
>    named_mutex::guard guard(&once_control2);
>    if (!once_control2) {
>      <init>
>      once_control2 = true;
>    }
>    once_control = true;
>  }
> 
> regards,
> alexander.
> 
> Alexander Terekhov/Germany/IBM@IBMDE@sources.redhat.com on 03/08/2005
> 10:55:53 AM
> 
> Sent by:    pthreads-win32-owner@sources.redhat.com
> 
> To:    Ross Johnson <rpj@callisto.canberra.edu.au>
> cc:    Pthreads-Win32 list <pthreads-win32@sources.redhat.com>
> Subject:    Re: starvation in pthread_once?
> 
> 
> > DCSI-TLS: (__declspec(thread) for control variable; DLL issues
> > aside for a moment)
> >
> >   if (!once_control) {
> >     named_mutex::guard guard(&once_control);
> >     if (!once_control) {
> >       <init>
> >       once_control = true;
> >     }
> >   }
> 
> Sorry, I meant:
> 
>  if (!once_control) {
>    named_mutex::guard guard(&once_control);
>    if (!once_control2) {
>      <init>
>      once_control2 = true;
>    }
>    once_control = true;
>  }
> 
> where once_control2 is a non-TLS flag.
> 
> regards,
> alexander.
> 
>


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