This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

Re: thread-local data access


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   `------------------------

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