首页 运维 网络学院 查看内容

linux 进程的最大线程个数

2015-1-15 10:45 711 0

摘要: 1. 可以通过下面的方法查到:[plain] view plaincopyprint?cat /proc/sys/kernel/threads-max  &nb...
关键词: nbsp plaincopyprint view threads thread totalpages SIZE proc 线程 cpp

1. 可以通过下面的方法查到:[plain] view plaincopyprint?cat /proc/sys/kernel/threads-max   15882  另外,一个进程实际的线程个数,可以从 /proc/{PID}/status里得出:[plain] view plaincopyprint?/proc/544#cat status   Name:   kpsmoused  State:  S (sleeping)  Tgid:   544  Pid:    544  PPid:   2  TracerPid:  0  Uid:    0   0   0   0  Gid:    0   0   0   0  FDSize: 32  Groups:   <strong>Threads:  1</strong>  SigQ:   0/7941  2。这个最大个数是在函数 fork_init 里算出来的:[cpp] view plaincopyprint?/*     * The default maximum number of threads is set to a safe  * value: the thread structures can take up at most half  * of memory.  */  max_threads = mempages / (8 * THREAD_SIZE / PAGE_SIZE);  [cpp] view plaincopyprint?#define THREAD_SIZE     8192  mempages 是物理内存的大小(以页面为单位)。可以用如下方法查到:[cpp] view plaincopyprint?cat /proc/zoneinfo | grep spanned | awk '{totalpages=totalpages+$2  } END {print totalpages}'  THREAD_SIZE为线程的栈大小。可以用 ulimit 查看:[cpp] view plaincopyprint?#ulimit -s  8192  
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

最新评论

返回顶部