From the makecontext manual ...
Due to limitations in the current implementation of pthread, makecontext should not be used in programs that are associated with the pthread (3) library (regardless of whether threads are used).
Now my question is: why does it not work and what are the alternative methods. Actually, I'm interested in switching stacks in a user-level stream at some points, but I see that when I do swapcontext, I get segmentation errors from time to time. 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 the c function.
Metallicpriest
source share