This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


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

Stack usage monitoring under POSIX threads


Hello eCos maintainers,
    The implementation of Cyg_HardwareThread::measure_stack_usage() function
(in kernel/current/include directory) calculates the stack usage from
stack_base, which I believe is not correct if the stack_limit is used (for
example in the pthread_setspecific(), which increases stack_limit to take
memory from stack) since the preset magic value (0xDEADBEEF) will likely be
overwritten by routines use stack limit.
     Here's my fix for the first 2 lines of
Cyg_HardwareThread::measure_stack_usage() to make it work with POSIX threads
when pthread_setspecific() is used.
[Original implementation, first 2 lines of measure_stack_usage()]
CYG_WORD *base=(CYG_WORD *)stack_base;
cyg_uint32 size= stack_size/sizeof(CYG_WORD);
[My fix]
#ifdef CYGFUN_KERNEL_THREADS_STACK_LIMIT
CYG_WORD *base= (CYG_WORD *)stack_limit;
cyg_uint32 size=(stack_size-int(stack_limit-stack_base))/sizeof(CYG_WORD);
#else    //the original implementation
CYG_WORD *base=(CYG_WORD *)stack_base;
cyg_uint32 size= stack_size/sizeof(CYG_WORD);
#endif

Best,
I-Jui Sung


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