From makecontext() manual...
Due to limitations in the current pthread implementation, makecontext should not be used in programs which link against the pthread(3) library (whether threads are used or not).
Now my question is, why it doesn't work and what are the alternative methods. Actually I'm interested in switching stacks in a user-level thread at some points, but I'm seeing that when I call swapcontext(), I get segmentation faults every now and then. What should I do?
I want to achieve something like this:
void thread_func(void * thread_args)
{
a();
b();
getcontext/makecontext/swapcontext to call c();
d();
....
}
So in this case, I want to use a separate stack when executing function c().