[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Stack base and thread-specific data

From: Igor Khavkine
Subject: Stack base and thread-specific data
Date: Wed, 8 Aug 2001 12:14:05 -0400
User-agent: Mutt/1.3.20i

I've noticed that some programs (like libgc, gccchecker) want
to know the address of the base of the current stack. Unlike some
of the otehr OS's we do not allocate the stack at a fixed address.
Moreover every thread has it's own stack the location of which
cannot be known at compile time. So a #define constant cant supply
the stack address ac compile time.

Right now the stack is allocated by the cthreads library, for
each new thread, the stack is aligned on 16MB boundaries and each
one is 16MB in size. That means we can get the stack base address
by anding a mask to the current stack pointer which clears some of
the less significant bits. This is exactly what's done when
the thread wants to access it's THREADVARS.

However, the pthreads specification contains interfaces to specify
the size and location of a newly created thread. That is not possible
with the above scheme where both the stack size and address are fixed
or can only take on a limired set of values. Most other solutions
that allow arbitrary stack sizes and locations would also involve
a performance loss (like adding an extra flavor to thread_info(),
or creating a task-wide hash for thread-specific data). I think
robustness is more important then speed here.

But I'd like to know what others think. Should we support these pthreads
interfaces in favor of robustness, or not support them in favor of
speed and internal simplicity?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]