previous | start | next

makecontext

void makecontext(ucontext_t *ucp, void *f(), int argc, ...)      
   

(See problem 3 in chapter 3?)

This creates a context and stores it in the struct pointed to by ucp. In particular, it sets up the stack so that when some thread switches to this context (how? by switching to the stack and returning) the function f will be called with the specified arguments on its stack.

A thread can switch to another context by calling swapcontext or setcontext.



previous | start | next