免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3780 | 回复: 5
打印 上一主题 下一主题

[Linux] pthread_create问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-10-29 15:49 |只看该作者 |倒序浏览
linux系统中对一个进程中创建多少个线程有限制吗?
我在测试一个程序时,想要创建2000个线程,但是在创建到一千多时就报错了 :pthread_create error:11,这是什么错误?什么原因造成的?

论坛徽章:
4
水瓶座
日期:2013-09-06 12:27:30摩羯座
日期:2013-09-28 14:07:46处女座
日期:2013-10-24 14:25:01酉鸡
日期:2014-04-07 11:54:15
2 [报告]
发表于 2013-10-29 16:16 |只看该作者
       EAGAIN The  system  lacked  the  necessary  resources  to  create  another  thread, or the system-imposed limit on the total number of threads in a process
              {PTHREAD_THREADS_MAX} would be exceeded.

论坛徽章:
0
3 [报告]
发表于 2013-10-29 16:22 |只看该作者
请问这段英文资料你是在哪里看到的?回复 2# linux_c_py_php


   

论坛徽章:
1
申猴
日期:2013-09-09 10:22:56
4 [报告]
发表于 2013-10-29 22:26 |只看该作者
#   define EAGAIN          11


int pthread_create( pthread_t * thread, void const *, unsigned (__stdcall * start_routine) (void*), void* arg )
{
    HANDLE h = (HANDLE)_beginthreadex( 0, 0, start_routine, arg, 0, 0 ) ;

    if( h != 0 )
    {
        *thread = h;
        return 0;
    }
    else
    {
        return EAGAIN;
    }
}


论坛徽章:
1
申猴
日期:2013-09-09 10:22:56
5 [报告]
发表于 2013-10-29 22:27 |只看该作者
或者man一下pthread_create

论坛徽章:
11
技术图书徽章
日期:2014-03-01 14:44:34天蝎座
日期:2014-05-21 22:11:59金牛座
日期:2014-05-30 17:06:14
6 [报告]
发表于 2013-10-30 15:49 |只看该作者
回复 1# Zoelov
如果线程栈是默认值,ulimit -s看下,一般为8MiB或10MiB,那么创建1000多线程,基本就8GiB以上,确认你的系统能否有这么大的内存地址空间


   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP