Linux内核中用于信号处理的堆栈框架 [英] Stack frame for signal handling in the Linux Kernel
问题描述
我看到在功能setup_rt_frame()
中分配了处理信号所需的堆栈帧.
I see that the stack frame the process needs to handle signals is allocated in the function setup_rt_frame()
.
我的问题是:它在哪里被取消分配?
My question is: where it is de-allocated?
谢谢!
推荐答案
setup_rt_frame()
sets stack for Real-time signals (see man 7 signal). It does 2 main things:
- 将用户进程的CPU上下文(在中断之前)从内核堆栈保存到用户堆栈.
对于ARM体系结构,它是在 setup_sigframe(). - 将返回地址(信号处理程序返回的位置)保存到用户堆栈.
返回地址将指向rt_sigreturn()
系统调用(请参见 man 2 sigreturn 了解详情).
对于ARM体系结构,它是在 setup_return().
- Saves CPU context of user process (before it was interrupted) from kernel stack to user stack.
For ARM architecture it's done in setup_sigframe(). - Saves return address (where signal handler returns) to user stack.
Return address will point tort_sigreturn()
syscall (see man 2 sigreturn for details).
For ARM architecture it's done in setup_return().
如您所见,信号处理程序完成后,它将自动返回到内核中的sys_rt_sigreturn()函数.此功能将从用户堆栈中恢复内核堆栈,并返回到中断的用户空间进程.
As you can see, once signal handler is finished, it will automatically return to sys_rt_sigreturn() function in kernel. This function will restore kernel stack from user stack and get back to interrupted user-space process.
所以,回答您的问题:
在哪里取消分配?
where it is de-allocated?
正在使用sys_rt_sigreturn()
功能对其进行恢复.
It's being restored in sys_rt_sigreturn()
function.
另请参阅:
[1] 信号如何在内部起作用?
[3] 信号处理的实现(请参见小节从传递信号(7)"到传递信号(12)")
[3] Implementation of signal handling (see sections "Delivering Signals (7)" to "Delivering Signals (12)")
这篇关于Linux内核中用于信号处理的堆栈框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!