Signal Stack

馋奶兔 提交于 2019-12-12 11:03:40

问题


I did read that signals need to have a separate stack, why and how do you think it is implemented ?

Are they dynamically allocated or statically allocated ? How is memory allocation done ? Is it the same for all signals ?


回答1:


The reason that signals need a separate stack is that, if the normal stack gets corrupted or overflows, the signal can still execute. I think the signal stack is usually allocated dynamically, but it could implemented be either way. You can set a new signal stack with sigaltstack. It is the same for all signals.




回答2:


Another, more esoteric reason is to create user-level threads. See the paper, "Portable Multithreading" by Ralf Engelschall: http://www.gnu.org/software/pth/rse-pmt.ps. It describes how the "signal stack trampoline trick" is used to effect userspace threading.



来源:https://stackoverflow.com/questions/841546/signal-stack

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