From 92cb8adb9a78516948a56e83854be732177fc607 Mon Sep 17 00:00:00 2001 From: jjenista Date: Fri, 29 Oct 2010 18:29:48 +0000 Subject: [PATCH] for original thread to become worker zero --- Robust/src/Runtime/workschedule.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Robust/src/Runtime/workschedule.c b/Robust/src/Runtime/workschedule.c index 45714f25..4cfb5e8f 100644 --- a/Robust/src/Runtime/workschedule.c +++ b/Robust/src/Runtime/workschedule.c @@ -337,6 +337,8 @@ void workScheduleInit( int numProcessors, pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_JOINABLE ); + workerDataArray[0].id = 0; + for( i = 1; i < numWorkSchedWorkers; ++i ) { workerDataArray[i].id = i; @@ -370,7 +372,10 @@ void workScheduleSubmit( void* workUnit ) { void workScheduleBegin() { int i; - // wait for all workers to exit gracefully + // original thread becomes a worker + workerMain( (void*) &(workerDataArray[0]) ); + + // then wait for all other workers to exit gracefully for( i = 1; i < numWorkSchedWorkers; ++i ) { pthread_join( workerDataArray[i].workerThread, NULL ); } -- 2.34.1