当我发送信号时机器内部会发生什么
我的意思是,我有一个对操作系统的请求,比如杀死 SIG_NUMBER PID,接下来会发生什么。操作系统采取了哪些操作等等。
非常感谢
I mean, i have a request for an operating system, like kill SIG_NUMBER PID, what happens next. What are the actions taken by operating system and so on.
Thanks much
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然取决于操作系统 - 但通常假设您有足够的权限将该信号传递给相关进程 - 那么操作系统将更改 proc 的进程状态。涉及内核内部。这通常会导致进程的一些“生命周期”状态变化 - 即被终止、终止、死亡、挂起..等。
对内核的实际调用(取决于操作系统)将通过系统调用或也许是通过某些适当的设备进行“ioctl”调用。
当轮到进程使用一些 cpu 时间时,proc 调度程序将考虑进程状态来确定下一步要做什么。由于涉及面很广,所以这里特意简单介绍一下。
我建议查看一些示例源代码 - 看看 Linux 发行版或 OpenSolaris(尽管这相当复杂)。
这里的例子 - 警告这非常复杂。
OpenSolaris 信号处理在内核中
Depends on the OS of course - but generally assuming you have sufficient privileges to deliver that signal to the process concerned - then the OS will alter the process state for the proc. concerned within the kernel. That will generally result in some "life cycle" state change for the process - i.e. to be terminated, terminating, dead, to be suspended .. etc.
The actual call into the kernel (depending on OS) will be via a system call or maybe an 'ioctl' call via some appropriate device.
When it's the process's turn for some cpu time the proc scheduler will take process state into account to determine what to do next. Deliberately brief here as its quite involved.
I'd suggest looking at some sample source - look at a Linux distro or OpenSolaris maybe (although that's quite complicated).
Example here - warning this is very complicated.
OpenSolaris signal handling in the kernel