Tag: ucontext

警告:’noreturn’function确实会返回

我正在做一个线程库(用uncontext.h改变上下文)。 我的函数是void类型,我无法返回。 但即使我没有返回,编译时会出现此警告: dccthread.c: In function ‘dccthread_init’: dccthread.c:184:1: warning: ‘noreturn’ function does return [enabled by default] } 这是函数的简化代码(没有一些细节): void dccthread_init(void (*func), int param) { int i=0; if (gerente==NULL) gerente = (dccthread_t *) malloc(sizeof(dccthread_t)); getcontext(&gerente->contexto); gerente->contexto.uc_link = NULL; gerente->contexto.uc_stack.ss_sp = malloc ( THREAD_STACK_SIZE ); gerente->contexto.uc_stack.ss_size = THREAD_STACK_SIZE; gerente->contexto.uc_stack.ss_flags = 0; gerente->tid=-1; makecontext(&gerente->contexto, gerente_escalonador, 0); if (principal==NULL) […]

为什么ucontext有这么高的开销?

Boost v1.59中Boost.Context的文档报告了以下性能比较结果: +———-+———————-+——————-+——————-+—————-+ | Platform | ucontext_t | fcontext_t | execution_context | windows fibers | +———-+———————-+——————-+——————-+—————-+ | i386 | 708 ns / 754 cycles | 37 ns / 37 cycles | ns / cycles | ns / cycles | | x86_64 | 547 ns / 1433 cycles | 8 ns / 23 cycles | 16 […]