Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does pthread_create() sometimes give EAGAIN on Cygwin port?

What does it mean when pthread_create() returns errno 11 (EAGAIN), "Resource temporarily unavailable"?

I am porting my application to Cygwin from it working great on Centos 4. Every once in a while, the application fails in its call to pthread_create(), but most of the time it works fine.

What does this mean is going wrong?

The Linux Centos 4 man page says:

   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.

I doubt I am hitting PTHREAD_THREADS_MAX, so how could the Cygwin system run out of resources to create another thread?

like image 464
WilliamKF Avatar asked Nov 28 '25 03:11

WilliamKF


1 Answers

From pthread_create() man page :

The pthread_create() function shall fail if:
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.

You can try again, after releasing some resources.

like image 181
BЈовић Avatar answered Nov 30 '25 18:11

BЈовић



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!