In article <11**********************@g47g2000cwa.googlegroups .com>
Sreekanth <sr********************@gmail.com> wrote:
I am trying to implement multiple threads using setjmp/longjmp
If you are using one of the longjmp() routines that I wrote (I have
written several), it checks to make sure you are not trying to use
it to implement threads.[%] If you are, it aborts.
The longjmp() function is not suitable for implementing threads.
In general, you must write assembly code to handle thread-switching.
Do not use longjmp().
[% Actually, it checks for a more general error, "going the wrong
way in the stack". This happens to include thread switches
approximately half the time. It is meant to catch the much more
common bug of attempting to jump into a stack frame that no longer
exists, and produce a debuggable crash instead of an undebuggable
one. The principle that longjmp() cannot be used to implement
threads still applies, however. Similarly, longjmp() cannot be
used to implement coroutines. Like threads, coroutine implementations
involve stack behavior that is not modeled by simple "up/down"
rules.]
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it
http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.