当前位置: 技术问答>linux和unix
再次发布pthread_create问题,认为是内存问题的就别回了,谢谢!
来源: 互联网 发布时间:2016-09-26
本文导语: ............................... error = pthread_create(&call_infos[tmpnum].runtime.threadid, &call_infos[tmpnum].runtime.attr, test_thread, &call_infos[tmpnum]); sleep(CALL_INTERVAL); if(error) { printf("Ins:%d error %d creat thread errorn",i,error); continue; } pthr...
...............................
error = pthread_create(&call_infos[tmpnum].runtime.threadid, &call_infos[tmpnum].runtime.attr, test_thread, &call_infos[tmpnum]);
sleep(CALL_INTERVAL);
if(error)
{
printf("Ins:%d error %d creat thread errorn",i,error);
continue;
}
pthread_detach(call_infos[tmpnum].runtime.threadid);
............................................
CALL_INTERVAL 如果等于1,即1秒创建一个线程,连续创建到44个都是OK的,到第45个就返回12类型错误,但CALL_INTERVAL超过1s就没问题,很困惑,高手解惑,谢谢!
error = pthread_create(&call_infos[tmpnum].runtime.threadid, &call_infos[tmpnum].runtime.attr, test_thread, &call_infos[tmpnum]);
sleep(CALL_INTERVAL);
if(error)
{
printf("Ins:%d error %d creat thread errorn",i,error);
continue;
}
pthread_detach(call_infos[tmpnum].runtime.threadid);
............................................
CALL_INTERVAL 如果等于1,即1秒创建一个线程,连续创建到44个都是OK的,到第45个就返回12类型错误,但CALL_INTERVAL超过1s就没问题,很困惑,高手解惑,谢谢!
|
[root@shwhg test]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
pending signals (-i) 1024
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 7167
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
你看你的这个值是多少, 有ulimit -s 设置下 数字越小,能创建的线程数目越多
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
pending signals (-i) 1024
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 7167
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
你看你的这个值是多少, 有ulimit -s 设置下 数字越小,能创建的线程数目越多