diff VSs.c @ 38:a951b38d2cfc

remove need for end_thread()
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Fri, 17 May 2013 17:49:49 +0200
parents c8d4f6d3c7d3
children 0715109abb08
line diff
     1.1 --- a/VSs.c	Wed May 15 15:25:55 2013 +0200
     1.2 +++ b/VSs.c	Fri May 17 17:49:49 2013 +0200
     1.3 @@ -85,8 +85,9 @@
     1.4  
     1.5        //VSs starts with one processor, which is put into initial environ,
     1.6        // and which then calls create() to create more, thereby expanding work
     1.7 -   seedSlv = VSs__create_slave_helper( fnPtr, initData,
     1.8 -                                     semEnv, semEnv->nextCoreToGetNewSlv++ );
     1.9 +   seedSlv = VSs__create_slave_helper( &VSs__run_thread , fnPtr, initData, semEnv, semEnv->nextCoreToGetNewSlv++ );
    1.10 +   //NB: this assumes that after VSs_init() nextCoreToGetNewSlv is still 0, 
    1.11 +   //    and also that there is more than 1 core.
    1.12     
    1.13        //seed slave is a thread slave, so make a thread's task stub for it
    1.14        // and then make another to stand for the seed's parent task.  Make
    1.15 @@ -221,14 +222,14 @@
    1.16        for( slotNum = 0; slotNum < NUM_ANIM_SLOTS; ++slotNum )
    1.17          {
    1.18  #ifdef IDLE_SLAVES
    1.19 -         idleSlv = VSs__create_slave_helper( &idle_fn, NULL, semanticEnv, 0);
    1.20 +         idleSlv = VSs__create_slave_helper( &VSs__run_thread, &idle_fn, NULL, semanticEnv, 0);
    1.21           idleSlv->coreAnimatedBy                = coreNum;
    1.22           idleSlv->animSlotAssignedTo            =
    1.23                                 _VMSMasterEnv->allAnimSlots[coreNum][slotNum];
    1.24           semanticEnv->idleSlv[coreNum][slotNum] = idleSlv;
    1.25  #endif
    1.26           
    1.27 -         slotTaskSlv = VSs__create_slave_helper( &idle_fn, NULL, semanticEnv, 0);
    1.28 +         slotTaskSlv = VSs__create_slave_helper(&VSs__run_thread, &idle_fn, NULL, semanticEnv, 0);
    1.29           slotTaskSlv->coreAnimatedBy            = coreNum;
    1.30           slotTaskSlv->animSlotAssignedTo        = 
    1.31                                 _VMSMasterEnv->allAnimSlots[coreNum][slotNum];
    1.32 @@ -493,7 +494,10 @@
    1.33     VMS_WL__send_dissipate_req( currVP );
    1.34   }
    1.35  
    1.36 -
    1.37 +void VSs__run_thread(TopLevelFnPtr fnPtr, void *initData){
    1.38 +    (*fnPtr)(initData);
    1.39 +    VSs__end_thread();
    1.40 +}
    1.41  
    1.42  //===========================================================================
    1.43  
    1.44 @@ -567,8 +571,10 @@
    1.45     VMS_WL__send_sem_request( &reqData, currVP );
    1.46   }
    1.47  
    1.48 -void plugin__end_VP(){ 
    1.49 -VSs__end_task();}
    1.50 +void VSs__run_task(TopLevelFnPtr fnPtr, void *initData){
    1.51 +    (*fnPtr)(initData);
    1.52 +    VSs__end_task();
    1.53 +}
    1.54  
    1.55  void
    1.56  VSs__taskwait()
    1.57 @@ -946,7 +952,6 @@
    1.58  void __entry_point(void* _args) {
    1.59      __main_args* args = (__main_args*) _args;
    1.60      __main_ret = __program_main(args->argc, args->argv);
    1.61 -    VSs__end_thread();
    1.62  }
    1.63  
    1.64  #undef main