亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区
Chinaunix
標(biāo)題:
請教 pthread_create 返回 ENOMEM的問題。
[打印本頁]
作者:
xrqun
時間:
2009-10-10 12:37
標(biāo)題:
請教 pthread_create 返回 ENOMEM的問題。
我使用pthread_create 創(chuàng)建了一個線程,結(jié)果返回ENOMEM錯誤
intPthreadStatus = pthread_create(&tnewThread, NULL, NewThread, NULL);
if(intPthreadStatus != 0)
{
printf("\n error is %d %s \n",intPthreadStatus,strerror(intPthreadStatus));
ERR("Thread create fail\n");
}
提示:
error is 12 Cannot allocate memory
Error Thread create fail。
不知道是什么問題。
作者:
epegasus
時間:
2009-10-10 12:40
創(chuàng)建的線程太多了吧
作者:
xrqun
時間:
2009-10-10 13:55
我就創(chuàng)建了第一個線程啊,總共需要創(chuàng)建5個線程,也不多啊
作者:
T-bagwell
時間:
2009-10-10 18:51
提示沒有內(nèi)存了?
作者:
xrqun
時間:
2009-10-11 10:26
是啊。搞不清楚是怎么回事。
作者:
C.J
時間:
2009-10-11 10:55
跟代碼+printk:wink:
作者:
xrqun
時間:
2009-10-14 10:42
問題解決了。
不過方向和“跟代碼+printk”相反。
我在系統(tǒng)起來之后 寫了個簡單的測試代碼
#include <stdio.h>
#include <pthread.h>
void* thread_info(void)
{
fprintf(stderr,"in thread_info function\n");
}
int main(void)
{
pthread_t thread_id;
int ret;
ret=pthread_create(&thread_id,NULL,(void*)thread_info,NULL);
if(ret != 0){
printf("cannot create new thread,%d:%s",ret,strerror(ret));
return 1;
}
sleep(1);
return 0;
}
發(fā)現(xiàn)還是提示內(nèi)存不足。
懷疑是內(nèi)核中使用的模塊太多的原因。
使用free命令:
total used free shared buffers
Mem: 56576 54376 2200 0 0
Swap: 0 0 0
Total: 56576 54376 2200
可以使用的只有 2200K。
再次確認是內(nèi)核中使用的模塊多的原因。
修改內(nèi)核配置文件,去掉不使用的模塊。
再次free
total used free shared buffers cached
Mem: 56960 27968 28992 0 0 7696
再次測試創(chuàng)建線程,測試通過。
結(jié)論:修改內(nèi)核時,將不用的內(nèi)核模塊去除掉。
歡迎光臨 Chinaunix (http://www.72891.cn/)
Powered by Discuz! X3.2