~/ cat test.c#include <errno.h>#include <pthread.h>static pthread_t thread;voID * test_thread(voID * ptr){ sleep(30); return(ptr);}voID thread_init(voID){ if (pthread_create( &thread,NulL,test_thread,NulL)) perror("Thread not created!");}int main(int argc,char ** argv){ thread_init(); sleep(30);}
当我在运行linux 2.6.14和BusyBox的系统上执行此代码(但使用bash 2.04g)时,我重新启动并启动上面的测试程序后得到的ps列表:
... 52 root SW [kswapd0] 667 root SW [mtdblockd] 710 root SWN [jffs2_gcd_mtd4] 759 root 980 S /bin/sh 760 root 500 S /bin/inetd 761 root 516 S /bin/boa 762 root 644 S /sbin/syslogd -n 763 root 640 S /sbin/klogd -n 766 root 1516 S /bin/sshd -i 767 root 1036 S -sh 768 root 420 S ./test 769 root 420 S ./test 770 root 420 S ./test 771 root 652 R ps
内核是2.6.14内核,添加了一些驱动程序模块.
解决方法 它可能是“线程管理器”线程.见 link的答案D.5.如果使用NPTL,您将看不到大多数现代linux系统上列出的额外进程.但我搜索过,听起来像BusyBox使用ulibc,我认为最近只添加了NPTL支持.所以我不确定,但我的猜测是你正在使用linuxThreads并将管理器线程视为额外的线程.
总结以上是内存溢出为你收集整理的linux – 为什么我看到的帖子多于我在`ps`列表中创建的数字?全部内容,希望文章能够帮你解决linux – 为什么我看到的帖子多于我在`ps`列表中创建的数字?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)