#include stdio.h> #include stdlib.h> #include ucontext.h> /* This is the iterator function. It is entered on the first call to * swapcontext, and loops from 0 to 9. Each value is saved in i_from_iterator, * and then swapcontext used to return to the main loop. The main loop prints * the value and calls swapcontext to swap back into the function. When the end &...
by gaocheng - Linux文档专区 - 2009-12-31 13:24:30 阅读(1068) 回复(0)
#include #include #include static ucontext_t uctx_main, uctx_func1, uctx_func2; #define die(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0) static void func1(void) { printf("func1: started\n"); printf("func1: swapcontext(&uctx_func1, &uctx_func2)\n"); if (swapcontext(&uctx_func1, &uctx_func2) == -1) die("swapcontext"); printf("func1: returning\n"); } static void f...
man 了一下,不太明白,google了一下好像也没太多讲解, 不知道有没有人可以指点一下这几个函数的大概用法来实现threaded program。 非常感谢!
man 了一下,不太明白,google了一下好像也没太多讲解, 不知道有没有人可以指点一下这几个函数的大概用法来实现threaded program。 非常感谢!