Hi I'm need to jump from a place to another...
But I would like to know which is better to use, setjmp or ucontext, things like:
Please give a little more information that I'm asking for, like examples or some docs...
I had searching on the web, but I only got exception handling in C like example of setjmp, and I got nothing about ucontex.h, I got that it was used for multitask, what's the difference of it and pthread?
Thanks a lot.
setjmp
is portable (ISO C89 and C99) and ucontext
(obsolescent in SUSv3 and removed from SUSv4/POSIX 2008) is not. However ucontext
was considerably more powerful in specification. In practice, if you used nasty hacks with setjmp
/longjmp
and signal handlers and alternate signal handling stacks, you could make these just about as powerful as ucontext
, but they were not "portable".
Neither should be used for multithreading. For that purpose POSIX threads (pthread functions). I have several reasons for saying this:
ucontext
was removed from the standards and might not be supported in future OS's (or even some present ones?)