pthread_create not enough space

百般思念 提交于 2019-12-11 20:37:29

问题


I'm using Pthreads with MinGW on Windows. A call to pthread_create returns a error which translates to "Not enough space". What kind of space does it refer to? Is the thread stack space?

int scannerThreadReturnValue = pthread_create(&parserThreadHandle, &attr, parserThread, (void *)filename);
    if(scannerThreadReturnValue != 0) {
        printf("Unable to create thread %s\n", strerror(errno));
    }
    else printf("Parser thread creation successfull\n");

回答1:


The error message most propably is wrong, as the pthread_* family of functions does not set errno. The error code is returned by the functions.

So mod you code like this:

int scannerThreadReturnValue = pthread_create(&parserThreadHandle, &attr, parserThread, (void*)filename);
if (scannerThreadReturnValue != 0)
{
  printf("Unable to create thread: %s\n", strerror(scannerThreadReturnValue));
}
else 
{
  printf("Parser thread creation successful.\n");
}

This will give you the correct error message.




回答2:


This is strange, though am not sure about MinGW, Yes it should be referring to the stack size. What kind of application is this ? did you create plenty threads prior to this parserThread ? . In ideal case should not failed in space issue.

Probably you can initiate thread attribute, and try to set stacksize before creating thread. So we can narrow down easily.



来源:https://stackoverflow.com/questions/16605925/pthread-create-not-enough-space

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!