delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/10/28/09:49:30

From: fjh AT cs DOT mu DOT OZ DOT AU (Fergus Henderson)
Subject: Re: proposal: join me for thread-safeness
28 Oct 1997 09:49:30 -0800 :
Message-ID: <199710281332.AAA00842.cygnus.gnu-win32@mundook.cs.mu.OZ.AU>
References: <199710280958 DOT KAA05194 AT chart DOT wins DOT uva DOT nl>
To: gnu-win32 AT cygnus DOT com
Cc: boncz AT wins DOT uva DOT nl

Peter Boncz <boncz AT wins DOT uva DOT nl> writes:

>To my surprice, the newlib/ (other than has been mentioned on this list) has
>been programmed with thread-safeness in mind. It uses the _REENT structure
>wherever appropriate. Please correct me if I'm wrong. It's just that there is
>just one instance of _REENT in cygwin.dll (called impure_ptr, or something 
>like it) that makes newlib unsafe at this moment.
>
>Producing a different _REENT for each thread will *not* be difficult to 
>implement since the WIN32 interface provides explicit functions to manipulate
>thread-local storage (Tls*()). Thus, it is not necessary in my view to
>modify gcc or the linker for dealing with .tls sections (as Gunther mentioned);
>you just redefine _REENT to the WIN32 call getting the thread-local data. 
>Maybe it is not hyper-efficient, but it will do.

Hmm... one call to TlsGetValue() for every occurrence of `stdout' or
`stdin', and, unless you hack the newlib code a fair bit, several such calls
for every occurence of `putchar()' or `getchar()'...  This will be
quite expensive for some programs.

Another alternative might be to reserve a register (perhaps one of the
segment registers ES, FS, or GS?) to hold a pointer to thread-local
storage.  However, I'm not sure if this is feasible.  You would need
some way of ensuring that this register is reloaded on context switches.
And if you use say EBX instead of ES/FS/GS, then the cost would be
losing a register... maybe this alternative is not so good.

--
Fergus Henderson <fjh AT cs DOT mu DOT oz DOT au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh AT 128 DOT 250 DOT 37 DOT 3         |     -- the last words of T. S. Garp.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019