liberty/support/specpriv-smtx-executive/control.cpp
/*
 * Description:
 *
 *  Forks processes for parallel execution, including auxiliary processes, and initialize them
 *
 * Arguments:
 *
 *  num_workers - number of real workers which will be used to actually run the program
 *  num_aux_workers - number of auxiliary workers, like try-commit
 *  current_iter - current iteration count
 *
 * Return:
 *
 *  worker ID of the process
 */
Forks processes for parallel execution, including auxiliary processes, and initialize them



number of real workers which will be used to actually run the program
num_aux_workers - number of auxiliary workers, like try-commit
current_iter - current iteration count



worker ID of the process
Forks processes for parallel execution including auxiliary processes and initialize them number of real workers which will be used to actually run the program num_aux_workers - number of auxiliary workers like try - commit current_iter - current iteration count worker ID of the process
static Wid spawn_workers(int32_t num_workers, int32_t n_aux_workers, Iteration current_iter)
{
#if DEBUG_ON
  fprintf(stderr, "spawn_workers called\n");
#endif
  Wid wid = 0;
  num_active_workers = num_workers;
  num_available_workers -= num_workers;
  worker_pids = (pid_t*)malloc( sizeof(pid_t) * (unsigned)(num_workers + n_aux_workers) );
#if (PROFILE || PROFILE_MEMOPS || PROFILE_WEIGHT)
  init_profile();
#endif
  set_try_commit_begin( (Wid)num_workers );
  unsigned num_all_workers = (unsigned)(num_workers + n_aux_workers);
  for ( ; wid < num_all_workers ; wid++)
  {
    pid_t pid = fork();
    if ( pid == 0 )
    {
      init_worker(current_iter, wid);
      return wid;
    }
    if (pid == -1)
    {
      perror("fork");
    }
    worker_pids[ wid ] = pid;
  }
  set_current_iter(current_iter);
  return MAIN_PROCESS_WID;
}
static Wid spawn_workers ( int32_t num_workers , int32_t n_aux_workers , Iteration current_iter ) { #if DEBUG_ON fprintf ( stderr , " \n " ) ; #endif Wid wid = 0 ; num_active_workers = num_workers ; num_available_workers -= num_workers ; worker_pids = ( pid_t * ) malloc ( sizeof ( pid_t ) * ( unsigned ) ( num_workers + n_aux_workers ) ) ; #if ( PROFILE || PROFILE_MEMOPS || PROFILE_WEIGHT ) init_profile ( ) ; #endif set_try_commit_begin ( ( Wid ) num_workers ) ; unsigned num_all_workers = ( unsigned ) ( num_workers + n_aux_workers ) ; for ( ; wid < num_all_workers ; wid ++ ) { pid_t pid = fork ( ) ; if ( pid == 0 ) { init_worker ( current_iter , wid ) ; return wid ; } if ( pid == -1 ) { perror ( " " ) ; } worker_pids [ wid ] = pid ; } set_current_iter ( current_iter ) ; return MAIN_PROCESS_WID ; }
Description:
  Forks processes for parallel execution, including auxiliary processes, and initialize them
Description : Forks processes for parallel execution including auxiliary processes and initialize them
// performance debugging // notify try-commit worker id // initial setup for worker process