Multithreading problems
Jan-Benedict Glaw
jbglaw at lug-owl.de
Thu Aug 3 18:44:41 UTC 2006
On Thu, 2006-08-03 11:34:50 -0700, Jeff Warren <tiny.laser at comcast.net> wrote:
> int StartThread(void* pMessage)
> {
> long retval;
> void **newstack;
>
> newstack = (void **) malloc(STACKSIZE);
Cast not needed.
> if (!newstack)
> return -1;
> newstack = (void **) (STACKSIZE + (char *) newstack);
> *--newstack = pMessage;
This isn't portable. A stack may grow bottom-to-top, too... You're
also "guessing" about the stack organization by pushing something to
it.
> This "quick and dirty way" has worked well for me and the kernel
> seems
> to be more efficient in how it handles these as they are distinct
> processes with no pthreads overhead. You lose the benefits of the
> pthreads implementation, but they were not important for my setup.
That approach is indeed useable, but if there's any remote chance that
parts of the sources are ever ported to a different CPU architecture
or even to a different platform, you'd either add "correct" code for
all possible combinations or place some strong #error instead.
MfG, JBG
--
Jan-Benedict Glaw jbglaw at lug-owl.de +49-172-7608481
Signature of: ...und wenn Du denkst, es geht nicht mehr,
the second : kommt irgendwo ein Lichtlein her.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20060803/660eb2b7/attachment-0002.pgp
More information about the uClibc
mailing list