Beispiel #1
0
/* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */
smx_actor_t MSG_process_create_from_SIMIX(
  const char *name, std::function<void()> code, void *data, sg_host_t host,
  double kill_time, xbt_dict_t properties,
  int auto_restart, smx_actor_t parent_process)
{
  msg_process_t p = MSG_process_create_with_environment(name, std::move(code), data, host, properties);
  if (p) {
    MSG_process_set_kill_time(p,kill_time);
    MSG_process_auto_restart_set(p,auto_restart);
  }
  return p;
}
Beispiel #2
0
/* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */
void MSG_process_create_from_SIMIX(smx_process_t* process, const char *name,
                                    xbt_main_func_t code, void *data,
                                    const char *hostname, double kill_time, int argc, char **argv,
                                    xbt_dict_t properties, int auto_restart)
{
  msg_host_t host = MSG_get_host_by_name(hostname);
  msg_process_t p = MSG_process_create_with_environment(name, code, data,
                                                      host, argc, argv,
                                                      properties);
  if (p) {
    MSG_process_set_kill_time(p,kill_time);
    MSG_process_auto_restart_set(p,auto_restart);
  }
  *((msg_process_t*) process) = p;
}
Beispiel #3
0
JNIEXPORT void JNICALL
Java_org_simgrid_msg_Process_setAutoRestart
    (JNIEnv *env, jobject jprocess, jboolean jauto_restart) {
  msg_process_t process = jprocess_to_native_process(jprocess, env);
  xbt_ex_t e;

  int auto_restart = jauto_restart == JNI_TRUE ? 1 : 0;

  if (!process) {
    jxbt_throw_notbound(env, "process", jprocess);
    return;
  }

  TRY {
    MSG_process_auto_restart_set(process,auto_restart);
  }
  CATCH (e) {
    xbt_ex_free(e);
  }
}
/** Main function */
int main(int argc, char *argv[])
{
  msg_error_t res = MSG_OK;
  unsigned long seed_platf_gen[] = {134, 233445, 865, 2634, 424242, 876543};
  unsigned long seed_trace_gen[] = {8865244, 356772, 42, 77465, 2098754, 8725442};
  int connected;
  int max_tries = 10;

  //MSG initialization
  MSG_init(&argc, argv);

  //Set up the seed for the platform generation
  platf_random_seed(seed_platf_gen);

  //Set up the RngStream for trace generation
  sg_platf_rng_stream_init(seed_trace_gen);

  XBT_INFO("creating nodes...");
  platf_graph_uniform(10);

  do {
    max_tries--;
    XBT_INFO("creating links...");
    platf_graph_clear_links();
    platf_graph_interconnect_waxman(0.9, 0.4);
    XBT_INFO("done. Check connectedness...");
    connected = platf_graph_is_connected();
    XBT_INFO("Is it connected : %s", connected ? "yes" : (max_tries ? "no, retrying" : "no"));
  } while(!connected && max_tries);

  if(!connected && !max_tries) {
    xbt_die("Impossible to connect the graph, aborting.");
  }

  XBT_INFO("registering callbacks...");
  platf_graph_promoter(promoter_1);
  platf_graph_labeler(labeler_1);

  XBT_INFO("promoting...");
  platf_do_promote();

  XBT_INFO("labeling...");
  platf_do_label();

  XBT_INFO("Putting it in surf...");
  platf_generate();

  XBT_INFO("Let's get the available hosts and dispatch work:");

  unsigned int i;
  msg_host_t host = NULL;
  msg_host_t host_master = NULL;
  msg_process_t process = NULL;
  xbt_dynar_t host_dynar = MSG_hosts_as_dynar();
  char** hostname_list =
    xbt_malloc(sizeof(char*) * xbt_dynar_length(host_dynar));

  xbt_dynar_foreach(host_dynar, i, host) {
    process = MSG_process_create("slave", slave, NULL, host);
    MSG_process_auto_restart_set(process, TRUE);
    hostname_list[i] = (char*) MSG_host_get_name(host);
  }