Changeset: d665ecc5f37e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d665ecc5f37e
Modified Files:
        monetdb5/mal/mal_dataflow.c
Branch: default
Log Message:

Produce exception when you can not create threads
The dataflow initialization routine assumed that it is always
possible to spawn a new thread. There is no such guarantee.
At least an exception should be raised when this happens.


diffs (49 lines):

diff --git a/monetdb5/mal/mal_dataflow.c b/monetdb5/mal/mal_dataflow.c
--- a/monetdb5/mal/mal_dataflow.c
+++ b/monetdb5/mal/mal_dataflow.c
@@ -352,22 +352,30 @@ DFLOWworker(void *t)
  * Create a set of DFLOW interpreters.
  * One worker will adaptively be available for each client.
  * The remainder are taken from the GDKnr_threads argument and
- * typically is equal to the number of cores
+ * typically is equal to the number of cores.
+ * A recursive MAL function call would make for one worker less,
+ * which limits the number of cores for parallel processing.
  * The workers are assembled in a local table to enable debugging.
  */
-static void
+static str
 DFLOWinitialize(void)
 {
        int i, limit;
 
        if (todo)
-               return;
+               return MAL_SUCCEED;
        MT_lock_set(&mal_contextLock, "DFLOWinitialize");
        todo = q_create(2048, "todo");
        limit = GDKnr_threads ? GDKnr_threads : 1;
-       for (i = 0; i < limit; i++)
+       for (i = 0; i < limit && i < THREADS; i++) {
                MT_create_thread(&workers[i], DFLOWworker, (void *) 
&workers[i], MT_THR_JOINABLE);
+               if ( workers[i] == 0 ) {
+                       MT_lock_unset(&mal_contextLock, "DFLOWinitialize");
+                       throw(MAL, "dataflow", "Can not create interpreter 
thread");
+               }
+       }
        MT_lock_unset(&mal_contextLock, "DFLOWinitialize");
+       return MAL_SUCCEED;
 }
  
 /*
@@ -586,7 +594,9 @@ runMALdataflow(Client cntxt, MalBlkPtr m
 
        /* check existence of workers */
        if (workers[0] == 0)
-               DFLOWinitialize();
+               ret = DFLOWinitialize();
+       if ( ret != MAL_SUCCEED)
+               return ret;
        assert(workers[0]);
        assert(todo);
 
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to