/** This function starts and ends simulation workflow. `main` accepts following arguments: @--cfg=tracing:yes enables tracing functionality of simgrid @--cfg=tracing/platform:yes enables platform tracing functionality of simgrid @--cfg=tracing/filename:<path to trace file> defines path to file simgrid writes to @--cfg=maxmin/concurrency_limit:100000 maximum number of simultaneously running processes in simulation @--cfg=storage/max_file_descriptors:220000" maximum number of simultaneously open (and not closed) file descriptors */ int main(int argc, char *argv[]){ YAML::Node config = YAML::LoadFile("config.yml"); const std::string model = config["model"].as<std::string>(); const std::string platform = config["platform"].as<std::string>(); const std::string deployment = config["deployment"].as<std::string>(); path_to_output = config["out.txt"].as<std::string>(); jobs_file = config["jobs"].as<std::string>(); input_files_file = config["input"].as<std::string>(); auto t1 = std::chrono::high_resolution_clock::now(); MSG_init(&argc, argv); MSG_create_environment(platform.c_str()); declare_trace_variables(); sem_requester = MSG_sem_init(1); MSG_function_register("evil", evil); MSG_function_register("scheduler", scheduler); MSG_function_register("tier1", tier1); MSG_function_register("killer", killer); MSG_function_register("tracer", tracer); MSG_function_register("initialize", initialize_file_labels); MSG_function_register("delete_unpop_file", delete_unpopular_file); MSG_launch_application(deployment.c_str()); current_model = (char*) model.c_str(); msg_error_t res = MSG_main(); XBT_INFO("Simulation time %f", MSG_get_clock()); fclose(FP); MSG_sem_destroy(sem_requester); MSG_sem_destroy(sem_link); // Clear info of name node /*std::map<string, FileData*>::iterator file_itr = name_node->begin(); while (file_itr != name_node->end()){ delete (*file_itr).second; name_node->erase(file_itr); file_itr++; }*/ // delete global_queue and name_node delete GLOBAL_QUEUE; //delete name_node; auto t2 = std::chrono::high_resolution_clock::now(); XBT_INFO("Real time of simulation: %ld seconds", std::chrono::duration_cast<std::chrono::seconds>(t2-t1).count()); return res != MSG_OK; }
int main(int argc, char* argv[]) { MSG_init(&argc, argv); MSG_create_environment(argv[1]); msg_host_t h = MSG_host_by_name("Fafard"); sem = MSG_sem_init(1); char** aliceTimes = xbt_new(char*, 9); int nbAlice = 0; aliceTimes[nbAlice++] = xbt_strdup("0"); aliceTimes[nbAlice++] = xbt_strdup("1"); aliceTimes[nbAlice++] = xbt_strdup("3"); aliceTimes[nbAlice++] = xbt_strdup("5"); aliceTimes[nbAlice++] = xbt_strdup("1"); aliceTimes[nbAlice++] = xbt_strdup("2"); aliceTimes[nbAlice++] = xbt_strdup("5"); aliceTimes[nbAlice++] = xbt_strdup("0"); aliceTimes[nbAlice++] = NULL; char** bobTimes = xbt_new(char*, 9); int nbBob = 0; bobTimes[nbBob++] = xbt_strdup("0.9"); bobTimes[nbBob++] = xbt_strdup("1"); bobTimes[nbBob++] = xbt_strdup("1"); bobTimes[nbBob++] = xbt_strdup("2"); bobTimes[nbBob++] = xbt_strdup("2"); bobTimes[nbBob++] = xbt_strdup("0"); bobTimes[nbBob++] = xbt_strdup("0"); bobTimes[nbBob++] = xbt_strdup("5"); bobTimes[nbBob++] = NULL; MSG_process_create_with_arguments(xbt_strdup("Alice"), peer, NULL, h, 8, aliceTimes); MSG_process_create_with_arguments(xbt_strdup("Bob"), peer, NULL, h, 8, bobTimes); msg_error_t res = MSG_main(); XBT_INFO("Finished\n"); return (res != MSG_OK); }
JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_init(JNIEnv * env, jobject obj, jint capacity) { msg_sem_t sem = MSG_sem_init((int) capacity); env->SetLongField(obj, jsyncro_field_Semaphore_bind, (jlong) (uintptr_t) (sem)); }