3

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?

WilliamKF
  • 41,123
  • 68
  • 193
  • 295
  • I've hit the same thing on several projects and always chalked it up to one of cygwin's many caveats. +1 – Tim Post Mar 08 '11 at 00:36
  • @Tim Post What was your work around? – WilliamKF Mar 08 '11 at 00:45
  • 1
    Most of the time you receive EAGAIN it means some resorce wasn't available and you should try again simply. This also happens when the function is interrupted (internally) by an interrupt or trap in the kernel part of the code and the internal state cannot be guaranteed to be consistent. So you should just try again. – RedX Mar 08 '11 at 00:55

1 Answers1

1

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.

BЈовић
  • 62,405
  • 41
  • 173
  • 273