/** * \brief Destroys a task. * * The user data (if any) should have been destroyed first. * * \param task the task you want to destroy * \see SD_task_create() */ void SD_task_destroy(SD_task_t task) { XBT_DEBUG("Destroying task %s...", SD_task_get_name(task)); /* First Remove all dependencies associated with the task. */ while (!task->predecessors->empty()) SD_task_dependency_remove(*(task->predecessors->begin()), task); while (!task->inputs->empty()) SD_task_dependency_remove(*(task->inputs->begin()), task); while (!task->successors->empty()) SD_task_dependency_remove(task, *(task->successors->begin())); while (!task->outputs->empty()) SD_task_dependency_remove(task, *(task->outputs->begin())); if (task->state == SD_SCHEDULED || task->state == SD_RUNNABLE) __SD_task_destroy_scheduling_data(task); int idx = xbt_dynar_search_or_negative(sd_global->return_set, &task); if (idx >=0) { xbt_dynar_remove_at(sd_global->return_set, idx, nullptr); } xbt_free(task->name); if (task->surf_action != nullptr) task->surf_action->unref(); xbt_free(task->host_list); xbt_free(task->bytes_amount); xbt_free(task->flops_amount); xbt_mallocator_release(sd_global->task_mallocator,task); XBT_DEBUG("Task destroyed."); }
int test_launcher(int argc, char *argv[]) { int test = 0; char **argvF; argvF = xbt_new(char*, 2); argvF[0] = xbt_strdup("process_daemon"); msg_host_t jupiter = MSG_get_host_by_name("Jupiter"); test = 1; // Create a process running a simple task on a host and turn the host off during the execution of the process. if (xbt_dynar_search_or_negative(tests, &test)!=-1){ XBT_INFO("Test 1:"); XBT_INFO(" Create a process on Jupiter"); argvF = xbt_new(char*, 2); argvF[0] = xbt_strdup("process_daemon"); MSG_process_create_with_arguments("process_daemon", process_daemon, NULL, jupiter, 1, argvF); MSG_process_sleep(3); XBT_INFO(" Turn off Jupiter"); MSG_host_off(jupiter); MSG_process_sleep(10); XBT_INFO("Test 1 seems ok, cool !(number of Process : %d, it should be 1 (i.e. the Test one))", MSG_process_get_number()); }