FreeBSD内核读书笔记-4.7-3

2009-05-13 05:15:09来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

【The Design and Implementation of The FreeBSD Operating System】

4.7 Signals 笔记 3
雨丝风片@chinaunix.net

【2. Given an action, p_signal() selects the appropriate thread and adds the signal to the thread's set of pending signals, td_siglist, and then does any implicit actions specific to that signal. For example, if the signal is a continue signal, SIGCONT, any pending signals that would normally cause the process to stop, such as SIGTTOU, are removed.】
【3. Next, psignal() checks whether the signal is being masked. If the thread is currently masking delivery of the signal, psignal()'s work is complete and it may return.】

对psignal()函数进行代码分离的CVS log如下:

Revision 1.220 / (download) - annotate - [select for diffs], Mon Mar 31 22:57:01 2003 UTC (3 years, 7 months ago) by jeff
Branch: MAIN
Changes since 1.219: +0 -0 lines
Diff to previous 1.219 (colored)
- The siglist in the proc holds signals that were blocked by all threads when they were delivered. In signotify() check to see if we have unblocked any of those signals and post them to the thread.
- Use td_sigmask instead of p_sigmask in all cases.
- In sigpending return both signals pending on the thread and proc. - Define a function, sigtd(), that finds the appropriate thread to deliver the signal to if psignal() has been called instead of tdsignal().
- Define a function, tdsignal(), that delivers a signal to a specific thread or if that thread has the signal blocked it may deliver it to the process where it will wait for a thread to unblock it.
- Since we are delivering signals to a specific thread we do not need to abort the sleep of all threads.
- Rename the old tdsignal() to tdsigwakeup().
- Save and restore the old signal mask to and from the thread.
这次是剥离出一个tdsignal()函数负责向特定线程发送信号。在2003年的6月28号又进一步从tdsignal()中分离出do_tdsignal()函数。
在进行了上述代码分离之后,tdsignal()和do_tdsignal()函数都是针对特定线程的了,而选择线程的代码则仍然在psignal()函数中:
---------------------------------------------------------------------FreeBSD6.1
1637 prop = sigprop(sig);
1638
1639 /*
1640  * Find a thread to deliver the signal to.
1641  */
1642 td = sigtd(p, sig, prop);
1643
1644 tdsignal(td, sig, SIGTARGET_P);
-----------------------------------------------/sys/kern/kern_sig.c---psignal()
sigprop()函数的代码如下:
---------------------------------------------------------------------FreeBSD6.1
236 static __inline int
237 sigprop(int sig)
238 {
239
240     if (sig > 0 && sig  NSIG)
241         return (sigproptbl[_SIG_IDX(sig)]);
242     return (0);
243 }
-----------------------------------------------/sys/kern/kern_sig.c---sigprop()

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:freebsd 的硬盘安装

下一篇:FreeBSD下讯弛CPU的自动降频【转载】