int main(int argc, char *argv[]) { MSG_init(&argc, argv); if (argc != 3) { printf("Usage: %s platform_file deployment_file\n", argv[0]); printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]); exit(1); } const char *platform_file = argv[1]; const char *application_file = argv[2]; MSG_create_environment(platform_file); MSG_function_register("receiver", receiver); MSG_function_register("sender", sender); MSG_launch_application(application_file); #ifndef DISABLE_THE_MUTEX mutex = xbt_mutex_init(); #endif msg_error_t res = MSG_main(); #ifndef DISABLE_THE_MUTEX xbt_mutex_destroy(mutex); mutex = NULL; #endif XBT_INFO("Simulation time %g", MSG_get_clock()); if (res == MSG_OK) return 0; else return 1; }
/** 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 */
/** @brief Destroy a message exchange queue. * * Any remaining content is leaked. */ void xbt_queue_free(xbt_queue_t * queue) { xbt_dynar_free(&((*queue)->data)); xbt_mutex_destroy((*queue)->mutex); xbt_cond_destroy((*queue)->not_full); xbt_cond_destroy((*queue)->not_empty); free(*queue); *queue = NULL; }
void xbt_thread_join(xbt_thread_t thread) { xbt_mutex_acquire(thread->mutex); xbt_assert(thread->joinable, "Cannot join on %p: wasn't created joinable", thread); if (!thread->done) { xbt_cond_wait(thread->cond, thread->mutex); xbt_mutex_release(thread->mutex); } xbt_mutex_destroy(thread->mutex); xbt_cond_destroy(thread->cond); free(thread->name); free(thread); }
void smpi_global_destroy(void) { int count = smpi_process_count(); int i; smpi_bench_destroy(); if (MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED){ while (smpi_group_unuse(smpi_comm_group(MPI_COMM_WORLD)) > 0); xbt_barrier_destroy(process_data[0]->finalization_barrier); }else{ smpi_deployment_cleanup_instances(); } for (i = 0; i < count; i++) { if(process_data[i]->comm_self!=MPI_COMM_NULL){ smpi_comm_destroy(process_data[i]->comm_self); } if(process_data[i]->comm_intra!=MPI_COMM_NULL){ smpi_comm_destroy(process_data[i]->comm_intra); } xbt_os_timer_free(process_data[i]->timer); xbt_mutex_destroy(process_data[i]->mailboxes_mutex); xbt_free(process_data[i]); } xbt_free(process_data); process_data = NULL; if (MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED){ smpi_comm_cleanup_smp(MPI_COMM_WORLD); smpi_comm_cleanup_attributes(MPI_COMM_WORLD); if(smpi_coll_cleanup_callback!=NULL) smpi_coll_cleanup_callback(); xbt_free(MPI_COMM_WORLD); } MPI_COMM_WORLD = MPI_COMM_NULL; if (!MC_is_active()) { xbt_os_timer_free(global_timer); } xbt_free(index_to_process_data); if(smpi_privatize_global_variables) smpi_destroy_global_memory_segments(); smpi_free_static(); }
static int xbt_thread_create_wrapper(int argc, char *argv[]) { smx_process_t self = SIMIX_process_self(); xbt_thread_t t = (xbt_thread_t) SIMIX_process_self_get_data(self); simcall_process_set_data(self, t->father_data); t->code(t->userparam); if (t->joinable) { t->done = 1; xbt_mutex_acquire(t->mutex); xbt_cond_broadcast(t->cond); xbt_mutex_release(t->mutex); } else { xbt_mutex_destroy(t->mutex); xbt_cond_destroy(t->cond); free(t->name); free(t); } return 0; }
int main(int argc, char *argv[]) { MSG_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); MSG_create_environment(argv[1]); MSG_function_register("receiver", receiver); MSG_function_register("sender", sender); MSG_launch_application(argv[2]); #ifndef DISABLE_THE_MUTEX mutex = xbt_mutex_init(); #endif msg_error_t res = MSG_main(); #ifndef DISABLE_THE_MUTEX xbt_mutex_destroy(mutex); mutex = NULL; #endif XBT_INFO("Simulation time %g", MSG_get_clock()); return res != MSG_OK; }
JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_nativeFinalize(JNIEnv * env, jobject obj) { xbt_mutex_t mutex; mutex = (xbt_mutex_t) (uintptr_t) env->GetLongField(obj, jsyncro_field_Mutex_bind); xbt_mutex_destroy(mutex); }