X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/41dd9405e023a6edd042bc02e5fd48c90aee5d56..779e0e58a8ec8674bef9f53c0f80ea021a4f5063:/src/instr/instr_msg_process.c diff --git a/src/instr/instr_msg_process.c b/src/instr/instr_msg_process.c index 87999ce166..99a8e630a4 100644 --- a/src/instr/instr_msg_process.c +++ b/src/instr/instr_msg_process.c @@ -8,182 +8,144 @@ #ifdef HAVE_TRACING -static xbt_dict_t process_containers = NULL; +XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_msg_process, instr, "MSG process"); -char *TRACE_process_alias_container(m_process_t process, m_host_t host, - char *output, int len) -{ - if (output) { - snprintf(output, len, "%p-%p", process, host); - return output; - } else { - return NULL; - } -} - -char *TRACE_process_container(m_process_t process, char *output, int len) -{ - if (output) { - snprintf(output, len, "%s-%p", MSG_process_get_name(process), process); - return output; - } else { - return NULL; - } -} - -void TRACE_msg_process_alloc(void) -{ - process_containers = xbt_dict_new(); -} - -void TRACE_msg_process_release(void) -{ - xbt_dict_free(&process_containers); -} - -static void TRACE_msg_process_location(m_process_t process) +/* + * TRACE_msg_set_process_category: tracing interface function + */ +void TRACE_msg_set_process_category(m_process_t process, const char *category, const char *color) { - char name[200], alias[200]; - m_host_t host = NULL; - if (!(IS_TRACING_PROCESSES || IS_TRACING_VOLUME)) - return; - - host = MSG_process_get_host(process); - TRACE_process_container(process, name, 200); - TRACE_process_alias_container(process, host, alias, 200); - - //check if process_alias container is already created - if (!xbt_dict_get_or_null(process_containers, alias)) { - pajeCreateContainer(MSG_get_clock(), alias, "PROCESS", - MSG_host_get_name(host), name); - if (IS_TRACING_PROCESSES) - pajeSetState(MSG_get_clock(), "category", alias, process->category); - xbt_dict_set(process_containers, xbt_strdup(alias), xbt_strdup("1"), - xbt_free); - } + xbt_die("deprecated"); } -static void TRACE_msg_process_present(m_process_t process) +char *instr_process_id (m_process_t proc, char *str, int len) { - char alias[200]; - m_host_t host = NULL; - if (!IS_TRACING_PROCESSES) - return; - - //updating presence state of this process location - host = MSG_process_get_host(process); - TRACE_process_alias_container(process, host, alias, 200); - pajePushState(MSG_get_clock(), "presence", alias, "presence"); + snprintf (str, len, "%s-%d", MSG_process_get_name(proc), MSG_process_get_PID(proc)); + return str; } /* - * TRACE_msg_set_process_category: tracing interface function + * Instrumentation functions to trace MSG processes (m_process_t) */ -void TRACE_msg_set_process_category(m_process_t process, - const char *category) +void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host, m_host_t new_host) { - char name[200]; - if (!IS_TRACING) - return; - - //set process category - process->category = xbt_strdup(category); - - //create container of type "PROCESS" to indicate location - TRACE_msg_process_location(process); - TRACE_msg_process_present(process); - - //create container of type "process" to indicate behavior - TRACE_process_container(process, name, 200); - if (IS_TRACING_PROCESSES) - pajeCreateContainer(MSG_get_clock(), name, "process", category, name); - if (IS_TRACING_PROCESSES) - pajeSetState(MSG_get_clock(), "process-state", name, "executing"); + if (TRACE_msg_process_is_enabled()){ + static long long int counter = 0; + char key[INSTR_DEFAULT_STR_SIZE]; + snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", counter++); + + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + //start link + container_t msg = getContainer(instr_process_id(process, str, len)); + type_t type = getType ("MSG_PROCESS_LINK", getRootType()); + new_pajeStartLink (MSG_get_clock(), getRootContainer(), type, msg, "M", key); + + //destroy existing container of this process + destroyContainer(getContainer(instr_process_id(process, str, len))); + + //create new container on the new_host location + msg = newContainer(instr_process_id(process, str, len), INSTR_MSG_PROCESS, getContainer(new_host->name)); + + //set the state of this new container + type = getType ("MSG_PROCESS_STATE", msg->type); + val_t value = getValueByName ("executing", type); + new_pajeSetState (MSG_get_clock(), msg, type, value); + + //end link + msg = getContainer(instr_process_id(process, str, len)); + type = getType ("MSG_PROCESS_LINK", getRootType()); + new_pajeEndLink (MSG_get_clock(), getRootContainer(), type, msg, "M", key); + } } -/* - * Instrumentation functions to trace MSG processes (m_process_t) - */ -void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host, - m_host_t new_host) +void TRACE_msg_process_create (m_process_t process) { - char alias[200]; - if (!(IS_TRACING_PROCESSES || IS_TRACING_VOLUME) || !IS_TRACED(process)) - return; + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; - //disabling presence in old_host (__TRACE_msg_process_not_present) - TRACE_process_alias_container(process, old_host, alias, 200); - if (IS_TRACING_PROCESSES) - pajePopState(MSG_get_clock(), "presence", alias); + m_host_t host = MSG_process_get_host(process); + container_t host_container = getContainer(host->name); + container_t msg = newContainer(instr_process_id(process, str, len), INSTR_MSG_PROCESS, host_container); - TRACE_msg_process_location(process); - TRACE_msg_process_present(process); + type_t type = getType ("MSG_PROCESS_STATE", msg->type); + val_t value = getValueByName ("executing", type); + new_pajeSetState (MSG_get_clock(), msg, type, value); + } } void TRACE_msg_process_kill(m_process_t process) { - char name[200]; - if (!IS_TRACING_PROCESSES || !IS_TRACED(process)) - return; + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; - TRACE_process_container(process, name, 200); - pajeDestroyContainer(MSG_get_clock(), "process", name); + //kill means that this process no longer exists, let's destroy it + destroyContainer (getContainer(instr_process_id(process, str, len))); + } } void TRACE_msg_process_suspend(m_process_t process) { - char name[200]; - if (!IS_TRACING_PROCESSES || !IS_TRACED(process)) - return; - - TRACE_process_container(process, name, 200); - pajeSetState(MSG_get_clock(), "process-state", name, "suspend"); + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + container_t process_container = getContainer (instr_process_id(process, str, len)); + type_t type = getType ("MSG_PROCESS_STATE", process_container->type); + val_t value = getValueByName ("suspend", type); + new_pajePushState (MSG_get_clock(), process_container, type, value); + } } void TRACE_msg_process_resume(m_process_t process) { - char name[200]; - if (!IS_TRACING_PROCESSES || !IS_TRACED(process)) - return; + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; - TRACE_process_container(process, name, 200); - pajeSetState(MSG_get_clock(), "process-state", name, "executing"); + container_t process_container = getContainer (instr_process_id(process, str, len)); + type_t type = getType ("MSG_PROCESS_STATE", process_container->type); + new_pajePopState (MSG_get_clock(), process_container, type); + } } void TRACE_msg_process_sleep_in(m_process_t process) { - char name[200]; - if (!IS_TRACING_PROCESSES || !IS_TRACED(process)) - return; - - TRACE_process_container(process, name, 200); - pajeSetState(MSG_get_clock(), "process-state", name, "sleep"); + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + container_t process_container = getContainer (instr_process_id(process, str, len)); + type_t type = getType ("MSG_PROCESS_STATE", process_container->type); + val_t value = getValueByName ("sleep", type); + new_pajePushState (MSG_get_clock(), process_container, type, value); + } } void TRACE_msg_process_sleep_out(m_process_t process) { - char name[200]; - if (!IS_TRACING_PROCESSES || !IS_TRACED(process)) - return; + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; - TRACE_process_container(process, name, 200); - pajeSetState(MSG_get_clock(), "process-state", name, "executing"); + container_t process_container = getContainer (instr_process_id(process, str, len)); + type_t type = getType ("MSG_PROCESS_STATE", process_container->type); + new_pajePopState (MSG_get_clock(), process_container, type); + } } void TRACE_msg_process_end(m_process_t process) { - char name[200], alias[200]; - m_host_t host = NULL; - if (!IS_TRACED(process)) - return; - - host = MSG_process_get_host(process); - TRACE_process_container(process, name, 200); - TRACE_process_alias_container(process, host, alias, 200); - if (IS_TRACING_PROCESSES) - pajeDestroyContainer(MSG_get_clock(), "process", name); - if (IS_TRACING_PROCESSES) - pajeDestroyContainer(MSG_get_clock(), "PROCESS", alias); + if (TRACE_msg_process_is_enabled()) { + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + //that's the end, let's destroy it + destroyContainer (getContainer(instr_process_id(process, str, len))); + } } #endif /* HAVE_TRACING */