This is the mail archive of the cygwin@sourceware.cygnus.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]

Re: proposal: join me for thread-safeness


Peter Boncz <boncz@wins.uva.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@cs.mu.oz.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@128.250.37.3         |     -- the last words of T. S. Garp.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


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