コード例 #1
0
ファイル: smx_context_sysv.c プロジェクト: tempbottle/simgrid
void SIMIX_ctx_sysv_factory_init(smx_context_factory_t *factory)
{
  smx_ctx_base_factory_init(factory);
  XBT_VERB("Activating SYSV context factory");

  (*factory)->finalize = smx_ctx_sysv_factory_finalize;
  (*factory)->create_context = smx_ctx_sysv_create_context;
  /* Do not overload that method (*factory)->finalize */
  (*factory)->free = smx_ctx_sysv_free;
  (*factory)->name = "smx_sysv_context_factory";

  if (SIMIX_context_is_parallel()) {
#ifdef CONTEXT_THREADS  /* To use parallel ucontexts a thread pool is needed */
    int nthreads = SIMIX_context_get_nthreads();
    sysv_parmap = xbt_parmap_new(nthreads, SIMIX_context_get_parallel_mode());
    sysv_workers_context = xbt_new(smx_ctx_sysv_t, nthreads);
    sysv_maestro_context = NULL;
    xbt_os_thread_key_create(&sysv_worker_id_key);
    (*factory)->stop = smx_ctx_sysv_stop_parallel;
    (*factory)->suspend = smx_ctx_sysv_suspend_parallel;
    (*factory)->runall = smx_ctx_sysv_runall_parallel;
#else
    THROWF(arg_error, 0, "No thread support for parallel context execution");
#endif
  } else {
    (*factory)->stop = smx_ctx_sysv_stop_serial;
    (*factory)->suspend = smx_ctx_sysv_suspend_serial;
    (*factory)->runall = smx_ctx_sysv_runall_serial;
  }    
}
コード例 #2
0
ファイル: smx_smurf.c プロジェクト: sbadia/simgrid
void SIMIX_request_destroy(void)
{
  int i, nthreads = SIMIX_context_get_nthreads();

  for(i=0; i < nthreads; i++)
    xbt_swag_free(req_lists[i]);

  xbt_free(req_lists);
}
コード例 #3
0
ファイル: smx_smurf.c プロジェクト: sbadia/simgrid
void SIMIX_request_init(void)
{
  s_smx_req_t req;
  int i, nthreads = SIMIX_context_get_nthreads();

  req_lists = xbt_new0(xbt_swag_t, nthreads);
  for(i=0; i < nthreads; i++)
    req_lists[i] = xbt_swag_new(xbt_swag_offset(req, reqtable_hookup));

}
コード例 #4
0
ファイル: ContextRaw.cpp プロジェクト: luizabeltrame/simgrid
void RawContextFactory::run_all_parallel()
{
#if HAVE_THREAD_CONTEXTS
  raw_threads_working = 0;
  if (raw_parmap == nullptr)
    raw_parmap = xbt_parmap_new(
      SIMIX_context_get_nthreads(), SIMIX_context_get_parallel_mode());
  xbt_parmap_apply(raw_parmap,
      [](void* arg) {
        smx_process_t process = static_cast<smx_process_t>(arg);
        RawContext* context = static_cast<RawContext*>(process->context);
        context->resume_parallel();
      },
      simix_global->process_to_run);
#else
  xbt_die("You asked for a parallel execution, but you don't have any threads.");
#endif
}
コード例 #5
0
ファイル: smx_smurf.c プロジェクト: sbadia/simgrid
smx_req_t SIMIX_request_pop(void)
{
  int i;
  smx_req_t req = NULL;
  int nthreads = SIMIX_context_get_nthreads();

  for(i=0; i < nthreads; i++){
    if((req = xbt_swag_extract(req_lists[i]))){
      XBT_DEBUG("Popped request %s (%d) of %s",
          SIMIX_request_name(req->issuer->request.call),
          req->issuer->request.call,
          req->issuer->name);
      return req;
    }
  }

  return NULL;
}