]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Retry pthread_create if the error code simply was EAGAIN.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 13 Nov 2002 22:58:14 +0000 (22:58 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 13 Nov 2002 22:58:14 +0000 (22:58 +0000)
git-svn-id: https://svn.dealii.org/trunk@6761 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/source/thread_management.cc
deal.II/doc/news/2002/c-3-4.html

index 39948f668cb9dec8d8d0024179cde2193894244f..2a75222f8f31472020448cec5bd329cb7b17d9f9 100644 (file)
 #  include <list>
 #endif
 
+#ifndef DEAL_II_USE_DIRECT_ERRNO_H
+#  include <errno.h>
+#else
+#  include </usr/include/errno.h>
+#endif
+#include <sys/errno.h>
+
+
 
 namespace Threads 
 {
@@ -227,9 +235,15 @@ namespace Threads
 
     tid_list.push_back (pthread_t());
 
-                                     // start new thread
-    const int error
-      = pthread_create (&tid_list.back(), 0, fun_ptr, fun_data);
+                                     // start new thread. retry until
+                                     // we either succeed or get an
+                                     // error other than EAGAIN
+    int error = 0;
+    do 
+      {
+       error = pthread_create (&tid_list.back(), 0, fun_ptr, fun_data);
+      }
+    while ( ! ((error == 0) || (error != EAGAIN)));
 
     Assert (error == 0, ExcInternalError());
   };
index eb1b40b48f6a5dc3962488571ddee43a350841f7..2f5332c42333db8662ba84b6752c0302a7ab2562 100644 (file)
@@ -180,7 +180,21 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
 <h3>base</h3>
 
 <ol>
-  <li> <p> Fixed: The <code class="member">write_text</code> and <code
+  <li> <p> 
+       Changed: In POSIX mode, when the <code class="member">ThreadManager</code>
+       class created a new thread through <code class="member">pthread_create</code>, 
+       it only checked for the error code and aborted if it was non-zero. Now, it
+       checks whether the error code is <code class="member">EAGAIN</code> and simply 
+       retries the call if this is the case. This may, in rare cases, lead to a
+       deadlock or an infinite loop, but will usually just wait until the respective
+       resources for thread creation are available from the operating system and will
+       then succeed.
+       <br>
+       (WB 2002/11/13)
+       </p>
+
+  <li> <p> 
+       Fixed: The <code class="member">write_text</code> and <code
        class="member">write_tex</code> functions of the <code
        class="class">TableHandler</code> class now check whether their
        <code>ofstream</code> arguments are in a proper state before

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.