setting of initial bottom of stack variable in pthread.c (again)
Jay
j2list468@yahoo.com
Tue Aug 8 15:10:00 GMT 2006
I posted this on the alpha mailing list, but this
might be a better place for it. From what I
understand, when __pthread_initial_thread_bos is set
in pthread.c, it must be set to cover both the initial
thread and manager thread. Looking at the
STACK_GROWS_DOWN case, it looks like this variable is
set to STACK_SIZE beyond the space it needs to to
cover the initial and manager thread. Graphically:
------------------- top of initial stack
| Initial thread |
| |
-------------------
| Manager thread |
| |
-------------------
| Free space |
| |
------------------- __pthread_initial_thread_bos
When the very first worker thread gets assigned its
stack space it is getting assigned the space in free
space which is above __pthread_initial_thread_bos
(instead of something below
__pthread_initial_thread_bos as it should since it is
not part of the initial thread), so when thread_self
is called from the first worker thread, thread_self
returns the initial thread, not the worker thread.
All other threads created after the first worker
thread are assigned memory below
__pthread_initial_thread_bos. The line that sets
__pthread_initial_thread_bos is
__pthread_initial_thread_bos =
(char *)(((long)CURRENT_STACK_FRAME - 2 *
STACK_SIZE) & ~(STACK_SIZE - 1));
Changing the 2 in the above equation to a 1 would
solve the problem of __pthread_initial_thread_bos
being set beyond the free space depicted above. Is
what is depicted above correct and it's a problem with
the memory the kernel is handing out, or is this a
bug, and the 2 should be a 1 since the stack is
growing down?
Thanks
Jay
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Libc-ports
mailing list