如果我错了,请纠正我这是我对信号的理解:
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.
那么这是否意味着信号只能在内核调度该进程即分配CPU时传递给进程?一个进程在CPU上实际执行时能得到一个信号吗?如果是这样,那怎么可能,过程如何知道信号正在等待(因为它在用户模式下执行,不能访问PCB)
说有多处理器机器,所以有真正的并行性,即多个进程同时执行。进程P1在cpu 1上执行,进程P2在cpu2上执行,现在进程P2(具有足够的权限)向进程P1发送一个信号。该信号现在将被传送到P1,或者在P1由于某种原因放弃CPU之后被传递,并且在稍后的时间内由内核再次重新安排,然后将该信号传送到过程P1。
请不要说这个问题是依赖于实现的。如果您发现正确的答案是实现定义,那么我正在寻找在Linux,FreeBSD或任何您知道的任何* nix平台的答案。
非常感谢您的帮助和耐心:)
问候
拉利