[ECOS] portability problem in pthread_create()
Lars Viklund
lars.viklund@axis.com
Tue Mar 5 08:56:00 GMT 2002
> From: Bart Veer [mailto:bartv@redhat.com]
> >>>>> "Lars" == Lars Viklund <lars.viklund@axis.com> writes:
>
> Lars> pthread_create() puts a pthread_info struct on the stack. If
> Lars> (sizeof(pthread_info) % sizeof(CYG_WORD)) != 0 this will
> Lars> make the stack unaligned which in turn will cause the assert
> Lars> in Cyg_HardwareThread::attach_stack() to fail.
> I am not convinced this is a real problem. The last field in the
> pthread_info structure is a pointer and the compiler is not allowed to
> rearrange fields within a structure, so the probability that
> (0 != (sizeof(pthread_info) % sizeof(CYG_WORD))) is low. This
> assumption could fail on strange architectures
Well, we have an architecture were this fails (no alignment requirements
and no padding in structs) so for us it is a real problem.
> but I suspect an awful lot of other
> code would fail as well
Most other things just work.
> Also the pthread_info structure is placed at the bottom (lowest memory
> location) of the stack, so for a typical descending stack it does not
> really matter whether or not the stacksize is word-aligned. Instead
> what really matters is that stackbase+stacksize remains word-aligned.
True.
> Have you seen this assertion trigger under normal circumstances?
Yes, on Axis ETRAX it does trigger when pthread_create() tries to
create the thread.
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
More information about the Ecos-discuss
mailing list