内核线程僵死如何解决?

bekars 2007-02-14 02:01:45
按照http://www.scs.ch/~frey/linux/kernelthreads.html的例子创建了5个内核线程,但是在关闭线程时,线程僵死。

在用户态可以用父进程wait解决,但是在内核里面如何避免僵死的内核线程?

root 1614 0.0 0.0 0 0 ? Z 10:34 0:00 [example thread <defunct>]
root 1615 0.0 0.0 0 0 ? Z 10:34 0:00 [example thread <defunct>]
root 1616 0.0 0.0 0 0 ? Z 10:34 0:00 [example thread <defunct>]
root 1617 0.0 0.0 0 0 ? Z 10:34 0:00 [example thread <defunct>]
root 1618 0.0 0.0 0 0 ? Z 10:34 0:00 [example thread <defunct>]
root 2664 0.0 0.4 6792 352 ? S 12:03 0:00 /usr/sbin/sshd
root 2666 0.0 1.0 4340 808 pts/2 S 12:04 0:00 -bash
root 2711 0.0 3.6 8140 2900 pts/2 S 13:48 0:00 vim kernel/signal.c
root 2725 0.0 0.0 0 0 ? Z 13:55 0:00 [example thread <defunct>]
root 2726 0.0 0.0 0 0 ? Z 13:55 0:00 [example thread <defunct>]
root 2727 0.0 0.0 0 0 ? Z 13:55 0:00 [example thread <defunct>]
root 2728 0.0 0.0 0 0 ? Z 13:55 0:00 [example thread <defunct>]
root 2729 0.0 0.0 0 0 ? Z 13:55 0:00 [example thread <defunct>]
...全文
826 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnwolf 2007-04-01
  • 打赏
  • 举报
回复
从例子程序看,线程退出后需要给他的父亲进程发送SIGCHLD信号
kill_proc(2, SIGCHLD, 1);
是发送给kevent的

你看看你的内核线程的父亲进程是谁,给发送一个SIGCHLD信号
aero_boy 2007-03-31
  • 打赏
  • 举报
回复
这说明你的线程已经运行结束了,你看看他们的父进程是不是没有wait或join来释放进程描述符。
InDepth 2007-03-28
  • 打赏
  • 举报
回复
僵死说明代码有问题,如果是完全用例子原代码的话,在insmod thread_mod.o后是不会僵死的,在用rmmod thread_mod后,各线程自动结束。
我想你可能修改了原代码,其中最可能的地方是进程间相互锁死,注意一下这个地方。
geopower 2007-02-27
  • 打赏
  • 举报
回复
试试 kill -HUP <ID>
geopower 2007-02-26
  • 打赏
  • 举报
回复
kill -9 <ID>
bekars 2007-02-26
  • 打赏
  • 举报
回复
楼上的兄弟,僵死的线程是不能用kill杀掉的

4,436

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧