comparison PR.c @ 290:c63b498d0a00

Fixed post-merge issues -- renames and includes..
author Sean Halle <seanhalle@yahoo.com>
date Thu, 05 Sep 2013 18:49:48 -0700
parents 15ee3fe10e3d b02b34681414
children
comparison
equal deleted inserted replaced
5:9d8fce3f2705 6:f17206f57988
63 PR__start() 63 PR__start()
64 { 64 {
65 PR_SS__create_topEnv(); 65 PR_SS__create_topEnv();
66 66
67 #ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE 67 #ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE
68 printf( "\n\n Running in SEQUENTIAL mode \n\n" ); 68 printf( "\n\n Running in SEQUENTIAL mode -- NUM_CORES: %d \n\n", NUM_CORES );
69 //Only difference between version with an OS thread pinned to each core and 69 //Only difference between version with an OS thread pinned to each core and
70 // the sequential version of PR is PR__init_Seq, this, and coreCtlr_Seq. 70 // the sequential version of PR is PR__init_Seq, this, and coreCtlr_Seq.
71 71
72 //Don't do anything here -- using main thread for all PR activity, so 72 //Don't do anything here -- using main thread for all PR activity, so
73 // do PR activity when main thread calls "wait for process to end" 73 // do PR activity when main thread calls "wait for process to end"
98 * inside the process. 98 * inside the process.
99 *-] Counter of num live slaves and num live tasks in the process 99 *-] Counter of num live slaves and num live tasks in the process
100 * 100 *
101 */ 101 */
102 PRProcess * 102 PRProcess *
103 PR__create_process( TopLevelFnPtr seed_Fn, void *seedData ) 103 PR__create_process( BirthFnPtr seed_Fn, void *seedData )
104 { SlaveVP *seedSlv; 104 { SlaveVP *seedSlv;
105 PRProcess *process; 105 PRProcess *process;
106 PRLangEnv **langEnvs, **langEnvsList; 106 PRLangEnv **langEnvs, **langEnvsList;
107 107
108 //This runs outside of the master lock, so use PR_WL form of malloc 108 //This runs outside of the master lock, so use PR_WL form of malloc
230 { coreCtlr_Seq( NULL ); 230 { coreCtlr_Seq( NULL );
231 flushRegisters(); //Not sure why here, but leaving to be safe 231 flushRegisters(); //Not sure why here, but leaving to be safe
232 process->executionIsComplete = TRUE; 232 process->executionIsComplete = TRUE;
233 } 233 }
234 #else 234 #else
235 //First get the "ACK" lock, then do normal wait for signal, then release 235 //This is called from main thread, so must use OS thread constructs to
236 // ACK lock, to let end-process know it can free the process struct 236 // force the main thread to block (suspend) until it is signalled that
237 pthread_mutex_lock( &(process->doneAckLock) ); 237 // the process is complete. One issue is that the mutex and cond variable
238 // are inside the process data struct, which is freed when the process
239 // ends!
238 pthread_mutex_lock( &(process->doneLock) ); 240 pthread_mutex_lock( &(process->doneLock) );
239 while( process->executionIsComplete != TRUE ) 241 while( process->executionIsComplete != TRUE )
240 { 242 {
241 pthread_cond_wait( &(process->doneCond), 243 pthread_cond_wait( &(process->doneCond),
242 &(process->doneLock) ); 244 &(process->doneLock) );