当前位置: 技术问答>linux和unix
关于Linux内核源代码的一个问题
来源: 互联网 发布时间:2016-03-27
本文导语: 请问在Linux2.4.0内核代码中, 函数static inline void forget_original_parent(struct task_struct * father) 遍历子进程为何要用遍历所有进程的方法? for_each_task(p) { if (p->p_opptr == father) { /* We dont want people slaying init */ ...
请问在Linux2.4.0内核代码中,
函数static inline void forget_original_parent(struct task_struct * father)
遍历子进程为何要用遍历所有进程的方法?
for_each_task(p) {
if (p->p_opptr == father) {
/* We dont want people slaying init */
p->exit_signal = SIGCHLD;
p->self_exec_id++;
p->p_opptr = reaper;
if (p->pdeath_signal) send_sig(p->pdeath_signal, p, 0);
}
}
我认为从最年轻的子进程开始沿着由各个task_struct结构中的指针p_osptr所形成的链表遍历,性能会更好。
但是在forget_original_parent()函数中为什么使用遍历所有进程的方法呢?
函数static inline void forget_original_parent(struct task_struct * father)
遍历子进程为何要用遍历所有进程的方法?
for_each_task(p) {
if (p->p_opptr == father) {
/* We dont want people slaying init */
p->exit_signal = SIGCHLD;
p->self_exec_id++;
p->p_opptr = reaper;
if (p->pdeath_signal) send_sig(p->pdeath_signal, p, 0);
}
}
我认为从最年轻的子进程开始沿着由各个task_struct结构中的指针p_osptr所形成的链表遍历,性能会更好。
但是在forget_original_parent()函数中为什么使用遍历所有进程的方法呢?
|
我的见解,不一定对啊。。。
因为在LINUX中,会经常产生孤儿进程,所有的孤儿进程都由INIT接管,
据此,由INIT开始遍历应该能容易提高查找的效率。
因为在LINUX中,会经常产生孤儿进程,所有的孤儿进程都由INIT接管,
据此,由INIT开始遍历应该能容易提高查找的效率。
|
mark!!!!!!!!!!!