bug fix....have to make sure we don't insert task into some other deque as insertion...
authorbdemsky <bdemsky>
Fri, 29 Oct 2010 07:06:11 +0000 (07:06 +0000)
committerbdemsky <bdemsky>
Fri, 29 Oct 2010 07:06:11 +0000 (07:06 +0000)
Robust/src/Runtime/workschedule.c

index e3c9db2ae60e32bcf7ed1fe65a0b03b1c80e6f12..45714f255d7bda375e6fd25ad29d61714c4f5700 100644 (file)
@@ -307,9 +307,9 @@ void workScheduleInit( int numProcessors,
   // protect memory allocation events coming
   CP_CREATE();
 
-  // the original thread will not become a worker, remember
-  myWorkerID = workerID_NOTAWORKER;
-
+  // the original thread is a worker
+  myWorkerID = 0;
+  oid = 1;
 
   pthread_mutex_init( &gclock,     NULL );
   pthread_mutex_init( &gclistlock, NULL );
@@ -337,7 +337,7 @@ void workScheduleInit( int numProcessors,
   pthread_attr_setdetachstate( &attr, 
                                PTHREAD_CREATE_JOINABLE );
 
-  for( i = 0; i < numWorkSchedWorkers; ++i ) {
+  for( i = 1; i < numWorkSchedWorkers; ++i ) {
 
     workerDataArray[i].id = i;
 
@@ -360,15 +360,8 @@ void workScheduleSubmit( void* workUnit ) {
   }
 #endif
 
-  if( myWorkerID == workerID_NOTAWORKER ) {
     CP_LOGEVENT( CP_EVENTID_DEBUG_A, CP_EVENTTYPE_BEGIN );
-    dqPushBottom( &(deques[0]), workUnit );
-    CP_LOGEVENT( CP_EVENTID_DEBUG_A, CP_EVENTTYPE_END );
-    return;
-  }
-
-    CP_LOGEVENT( CP_EVENTID_DEBUG_A, CP_EVENTTYPE_BEGIN );
-  dqPushBottom( &(deques[myWorkerID]), workUnit );
+    dqPushBottom( &(deques[myWorkerID]), workUnit );
     CP_LOGEVENT( CP_EVENTID_DEBUG_A, CP_EVENTTYPE_END );
 }
 
@@ -378,7 +371,7 @@ void workScheduleBegin() {
   int i;
 
   // wait for all workers to exit gracefully
-  for( i = 0; i < numWorkSchedWorkers; ++i ) {
+  for( i = 1; i < numWorkSchedWorkers; ++i ) {
     pthread_join( workerDataArray[i].workerThread, NULL );
   }