开发者

why user level threads need no system call?

开发者 https://www.devze.com 2023-02-22 22:54 出处:网络
I have read that the advantage of user-level threads is that they do not require kernel calls for switching. Does loading the registers (IP, SP) not require system call ? I programmed user-level threa

I have read that the advantage of user-level threads is that they do not require kernel calls for switching. Does loading the registers (IP, SP) not require system call ? I programmed user-level threads in C using the fu开发者_如何学Gonctions - getcontext, setcontext ? Don't these function invoke system calls ?


(Most of) the registers visible to user-mode code can also be saved/restored in user-mode code.

Since a user-mode thread (at least normally) doesn't get switched preemptively, you don't normally need to save all the registers anyway. A typical implementation uses setjmp and longjmp to save/restore the necessary state. These typically don't involve any user/kernel mode switching.

0

精彩评论

暂无评论...
验证码 换一张
取 消