next up previous contents
Next: Schedule function Up: Thread Library Functions Previous: The curr_thread pointer   Contents

Thread Init Function

void *thread_init_function(void *(*start_add)(void *),void *param)
{
  spin_unlock(&(scheduler->sched_lock));
  do_Context_Switch=1;
  
  start_add(param); 
  
  do_Context_Switch=0;
  spin_lock(&(scheduler->sched_lock));
  
  .......................................
  Re initialize the context of the thread
  .......................................

  scheduler->set_mode(curr_thread,THREAD_EXITED);

  ..............................
  Context Switch to a new thread
  ..............................
  
}

This is the function from which every thread starts executing. The arguements are the starting function of that particular thread and the parameter to be passed to that starting functions9.3.

This function does some initialization stuff, unlocks the spin_lock9.4 and then calls start_addr with param as parameter.

When the function start_addr returns, ie when the thread has exited, the scheduler object is informed about the completion of the thread. The context of the thread is also initialized to it's starting state.



Soumyadeb Mitra 2002-08-07