Does each thread have its own stack?

余生颓废 提交于 2021-02-05 21:38:32

问题


When I create multiple threads from a process, then does each thread have its own stack, or is it that they share the stack of their parent process. What happens when a thread makes a system call? Do threads also maintain their own kernel stack like processes?


回答1:


Yes threads have their own stacks and their own kernel stacks (e.g. linux).

When a thread makes a system call, you trap into kernel mode (from user mode), you pass the arguments to the kernel, the arguments are checked, the kernel does w/e it needs to do (in the kernel stack), returns the final value back to the thread and you go back to user mode.



来源:https://stackoverflow.com/questions/18350219/does-each-thread-have-its-own-stack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!