[openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- From: François Revol <revol@xxxxxxx>
- To: openbeos@xxxxxxxxxxxxx
- Date: Tue, 10 Dec 2002 18:08:33 +0100 (MET)
En réponse à Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>:
> > Although the POSIX standard may declare that these functions need
> not
> > be thread-safe, an implementation where they are thread-safe would
> > certainly satisfy POSIX. In BeOS, where threads are pervasive, I'd
> > argue that all of the standard library should be thread-safe.
>
> No, those functions *can't* be made thread-safe easily, just have a
> look at their prototypes - they depend on global data. You would need
> to put all global data/strings into fixed TLS slots which is certainly
> not desirable.
Yes, though for things like this I'd do:
_init()
(or initialize_before())
{
...
_malloc_init(); // so we can use it :)
// alloc one TLS,
// malloc() the static "string"
// and use the TLS as a pointer to it
}
strtime()
{
char *global = opinter_from_TLS();
if (!global) {
malloc(); // new thread, so malloc for this thread
}
//usual stuff
}
Btw, I'm still searching the exact differences between
initialize_before and initialize_after
terminate_before and terminate_after
Anyone in the know ?
François.
- References:
- [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- From: Axel =?iso-8859-1?q?D=F6rfler
Other related posts:
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- » [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- [openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting
- From: Axel =?iso-8859-1?q?D=F6rfler