thread-local data access
Ulrich Drepper
drepper@redhat.com
Wed Sep 27 08:16:00 GMT 2000
Jakub Jelinek <jakub@redhat.com> writes:
> static inline pthread_descr thread_self (void)
> {
> #ifdef THREAD_SELF
> return THREAD_SELF;
> #else
> char *sp = CURRENT_STACK_FRAME;
> return __pthread_descr_array[(unsigned long)sp >> 16];
> #endif
> }
You will need a 256k array for this. We had to make the decision for
the thread library and decided not to do it that way.
Also, some applications allocate really small stacks for the threads
(if it's known they don't need much) like this:
char stacks[N][4096];
pthread_attr_t attr[N];
for (n = ...)
pthread_attr_setstack (&attr[n], stacks[n], 4096);
You cannot safely assume that you have 64 for your own.
--
---------------. ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Red Hat `--' drepper at redhat.com `------------------------
More information about the Libc-hacker
mailing list