Пример #1
0
/** Main function */
int main(int argc, char *argv[])
{
    msg_error_t res = MSG_OK;

    /* Argument checking */
    MSG_init(&argc, argv);
    if (argc < 3) {
        XBT_CRITICAL("Usage: %s platform_file deployment_file\n", argv[0]);
        XBT_CRITICAL("example: %s msg_platform.xml msg_deployment_suspend.xml\n",
                     argv[0]);
        exit(1);
    }

    /* Simulation setting */
    MSG_create_environment(argv[1]);

    /* Application deployment */
    MSG_function_register("emigrant", emigrant);
    MSG_function_register("policeman", policeman);
    MSG_launch_application(argv[2]);

    /* Run the simulation */
    mutex = xbt_mutex_init();
    cond = xbt_cond_init();
    res = MSG_main();
    XBT_INFO("Simulation time %g", MSG_get_clock());
    xbt_cond_destroy(cond);
    xbt_mutex_destroy(mutex);

    if (res == MSG_OK)
        return 0;
    else
        return 1;
}                               /* end_of_main */
Пример #2
0
xbt_thread_t xbt_thread_create(const char *name, void_f_pvoid_t code,
                               void *param, int joinable)
{
  xbt_thread_t res = xbt_new0(s_xbt_thread_t, 1);
  res->name = xbt_strdup(name);
  res->userparam = param;
  res->code = code;
  res->father_data = SIMIX_process_self_get_data(SIMIX_process_self());
  /*   char*name = bprintf("%s#%p",SIMIX_process_self_get_name(), param); */
  simcall_process_create(&res->s_process, name,
                           xbt_thread_create_wrapper, res,
                           SIMIX_host_self_get_name(), -1.0, 0, NULL,
                           /*props */ NULL,0);
  res->joinable = joinable;
  res->done = 0;
  res->cond = xbt_cond_init();
  res->mutex = xbt_mutex_init();
  //   free(name);
  return res;
}