linux进程接受信号,linux – 一个进程如何知道它已经收到一个信号
如果我錯(cuò)了,請糾正我這是我對信號(hào)的理解:
As far as i know, signal generation
and signal delivery are 2 different
things. In order to generate a signal,
the OS simply sets a bit in a bitarray
maintained in the Process Control
Block(PCB) of the process. Each bit
corresponds to a particular signal,
and when a bit is set, it means the
signal corresponding to the bit is
pending.
Delivery: Before transferring control
back to a process in user mode, the
Kernel always checks the pending
signals for this process. This check
must happen in Kernel space because
some signals can never be ignored by a
process – namely SIGSTOP and SIGKILL.
那么這是否意味著信號(hào)只能在內(nèi)核調(diào)度該進(jìn)程即分配CPU時(shí)傳遞給進(jìn)程?一個(gè)進(jìn)程在CPU上實(shí)際執(zhí)行時(shí)能得到一個(gè)信號(hào)嗎?如果是這樣,那怎么可能,過程如何知道信號(hào)正在等待(因?yàn)樗谟脩裟J较聢?zhí)行,不能訪問PCB)
說有多處理器機(jī)器,所以有真正的并行性,即多個(gè)進(jìn)程同時(shí)執(zhí)行。進(jìn)程P1在cpu 1上執(zhí)行,進(jìn)程P2在cpu2上執(zhí)行,現(xiàn)在進(jìn)程P2(具有足夠的權(quán)限)向進(jìn)程P1發(fā)送一個(gè)信號(hào)。該信號(hào)現(xiàn)在將被傳送到P1,或者在P1由于某種原因放棄CPU之后被傳遞,并且在稍后的時(shí)間內(nèi)由內(nèi)核再次重新安排,然后將該信號(hào)傳送到過程P1。
請不要說這個(gè)問題是依賴于實(shí)現(xiàn)的。如果您發(fā)現(xiàn)正確的答案是實(shí)現(xiàn)定義,那么我正在尋找在Linux,FreeBSD或任何您知道的任何* nix平臺(tái)的答案。
非常感謝您的幫助和耐心:)
問候
拉利
總結(jié)
以上是生活随笔為你收集整理的linux进程接受信号,linux – 一个进程如何知道它已经收到一个信号的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle v$access执行很慢,
- 下一篇: linux 其他常用命令