5 ms·
need to drop down to assembly to implement resumable function/fibers to avoid the syscall costs of ucontext/setjmp/longjmp Which syscalls would be involved in
by sigjuice 7y ago
need to drop down to assembly to implement resumable function/fibers to avoid the syscall costs of ucontext/setjmp/longjmp
Which syscalls would be involved in setjmp/longjmp?
- mratsim 7y agoSee http://www.1024cores.net/home/lock-free-algorithms/tricks/fibers http://www.1024cores.net/home/lock-free-algorithms/tricks/fi... on ucontext And for longjmp, Apple source for example https://opensource.apple.com/source/Libc/Libc-262/i386/sys/setjmp.s.auto.html https://opensource.apple.com/source/Libc/Libc-262/i386/sys/s.... It does seem like glibc impl doesn't involve syscalls: https://groups.google.com/forum/#!topic/comp.unix.programmer/LvUP9H-7Aes https://groups.google.com/forum/#!topic/comp.unix.programmer...
- loeg 7y agoFor inexplicable reasons, ucontext/setjmp/longjmp include signal masks, which, for lack of VDSO implementation, must be obtained by invoking syscalls. (FreeBSD provides the non-portable _setjmp/_longjmp, which do not preserve signal mask state and avoid the syscall. There are also the POSIX sigsetjmp/siglongjmp, which with savesigs=0 may bypass the syscalls as well. Both FreeBSD and Linux provide the POSIX routines.)