示例#1
0
void * master_worker_computation_routine(void * arg) {
    launchArg_t * launchArg = (launchArg_t *) arg;
    ocrPolicyDomain_t * pd = launchArg->PD;
    ocrWorker_t * worker = (ocrWorker_t *) launchArg->arg;
    DPRINTF(DEBUG_LVL_INFO, "Starting scheduler routine of master worker %d\n", get_worker_id(worker));
    worker_loop(pd, worker);
    return NULL;
}
示例#2
0
int
main(int argc, char *argv[])
{
  int rc;

  int am_server;

  int num_types = 1;
  int type_vect[2] = { CMDLINE };


  printf("batcher...\n");

  rc = MPI_Init( &argc, &argv );
  assert(rc == MPI_SUCCESS);

  int my_world_rank, worker_rank;
  MPI_Comm_rank( MPI_COMM_WORLD, &my_world_rank );

  int num_servers = 1;

  MPI_Comm worker_comm;
  rc = ADLB_Init(num_servers, num_types, type_vect, &am_server,
                  MPI_COMM_WORLD, &worker_comm);
  if (! am_server)
    // worker rank
    MPI_Comm_rank(worker_comm, &worker_rank);

  MPI_Barrier(MPI_COMM_WORLD);
  double start_time = MPI_Wtime();

  if (am_server )
  {
    // server rank
    ADLB_Server(3000000);
  }
  else
  {
    // worker rank
    if (worker_rank == 0)
      // master worker: read and put commands
      put_commands(argc, argv);

    // All application processes, including the master worker,
    // execute this loop:
    worker_loop();

    if (worker_rank == 0)
    {
      double end_time = MPI_Wtime();
      printf("TOOK: %.3f\n", end_time-start_time);
    }
  }

  ADLB_Finalize();
  MPI_Finalize();
  return(0);
}
示例#3
0
void * worker_computation_routine(void * arg) {
    // Need to pass down a data-structure
    launchArg_t * launchArg = (launchArg_t *) arg;
    ocrPolicyDomain_t * pd = launchArg->PD;
    ocrWorker_t * worker = (ocrWorker_t *) launchArg->arg;
    // associate current thread with the worker
    associate_comp_platform_and_worker(pd, worker);
    // Setting up this worker context to takeEdts
    // This assumes workers are not relocatable
    DPRINTF(DEBUG_LVL_INFO, "Starting scheduler routine of worker %d\n", get_worker_id(worker));
    worker_loop(pd, worker);
    return NULL;
}
示例#4
0
void worker_client(int worker_mode, int indx, int shid, char **env) {
#else
void worker_client(int worker_mode, int indx, int shid) {
#endif

    gm_log( GM_LOG_TRACE, "%s worker client started\n", (worker_mode == GM_WORKER_STATUS ? "status" : "job" ));

    /* set signal handlers for a clean exit */
    signal(SIGINT, clean_worker_exit);
    signal(SIGTERM,clean_worker_exit);

    worker_run_mode = worker_mode;
    shm_index       = indx;
    shmid           = shid;
    current_pid     = getpid();

    gethostname(hostname, GM_BUFFERSIZE-1);

    /* create worker */
    if(set_worker(&worker) != GM_OK) {
        gm_log( GM_LOG_ERROR, "cannot start worker\n" );
        clean_worker_exit(0);
        _exit( EXIT_FAILURE );
    }

    /* create client */
    if ( create_client( mod_gm_opt->server_list, &client ) != GM_OK ) {
        gm_log( GM_LOG_ERROR, "cannot start client\n" );
        clean_worker_exit(0);
        _exit( EXIT_FAILURE );
    }

    /* create duplicate client */
    if( mod_gm_opt->dupserver_num ) {
        if ( create_client_dup( mod_gm_opt->dupserver_list, &client_dup ) != GM_OK ) {
            gm_log( GM_LOG_ERROR, "cannot start client for duplicate server\n" );
            _exit( EXIT_FAILURE );
        }
    }

#ifdef EMBEDDEDPERL
    if(init_embedded_perl(env) == GM_ERROR) {
        _exit( EXIT_FAILURE );
    }
#endif

    worker_loop();

    return;
}
示例#5
0
文件: bn.c 项目: sh19910711/webn
int main(int argc, char const* argv[]) {
    init_bn();
    steps = COLS - MAX_AA_WIDTH - 1;
    base_line = LINES / 2;

    /* 基準面描画 */
    attrset(COLOR_PAIR(BN_COLOR_PAIR_GG));
    mvhline(base_line, 0, '^', COLS - 1);

    draw = bird[0];

    attrset(COLOR_PAIR(BN_COLOR_PAIR_DEFAULT));

    worker_loop(NULL);
}
示例#6
0
文件: dmq.c 项目: 4N7HR4X/kamailio
/**
 * initialize children
 */
static int child_init(int rank)
{
  	int i, newpid;
	if (rank == PROC_MAIN) {
		/* fork worker processes */
		for(i = 0; i < num_workers; i++) {
			init_worker(&workers[i]);
			LM_DBG("starting worker process %d\n", i);
			newpid = fork_process(PROC_NOCHLDINIT, "DMQ WORKER", 0);
			if(newpid < 0) {
				LM_ERR("failed to form process\n");
				return -1;
			} else if(newpid == 0) {
				/* child - this will loop forever */
				worker_loop(i);
			} else {
				workers[i].pid = newpid;
			}
		}
		/* notification_node - the node from which the Kamailio instance
		 * gets the server list on startup.
		 * the address is given as a module parameter in dmq_notification_address
		 * the module MUST have this parameter if the Kamailio instance is not
		 * a master in this architecture
		 */
		if(dmq_notification_address.s) {
			notification_node = add_server_and_notify(&dmq_notification_address);
			if(!notification_node) {
				LM_ERR("cannot retrieve initial nodelist from %.*s\n",
				       STR_FMT(&dmq_notification_address));
				return -1;
			}
		}
		return 0;
	}
	if(rank == PROC_INIT || rank == PROC_TCP_MAIN) {
		/* do nothing for the main process */
		return 0;
	}

	pid = my_pid();
	return 0;
}
void worker_main(int fd[2])
{
	close(fd[0]);
		
	worker_loop(fd[1]);
}