1 /* Copyright (c) 2010. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "instr/instr_private.h"
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_msg_process, instr, "MSG process");
14 * TRACE_msg_set_process_category: tracing interface function
16 void TRACE_msg_set_process_category(m_process_t process, const char *category, const char *color)
18 xbt_die("deprecated");
21 char *instr_process_id (m_process_t proc, char *str, int len)
23 snprintf (str, len, "%s-%d", MSG_process_get_name(proc), MSG_process_get_PID(proc));
28 * Instrumentation functions to trace MSG processes (m_process_t)
30 void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host, m_host_t new_host)
32 if (TRACE_msg_process_is_enabled()){
33 static long long int counter = 0;
34 char key[INSTR_DEFAULT_STR_SIZE];
35 snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", counter++);
37 int len = INSTR_DEFAULT_STR_SIZE;
38 char str[INSTR_DEFAULT_STR_SIZE];
41 container_t msg = getContainer(instr_process_id(process, str, len));
42 type_t type = getType ("MSG_PROCESS_LINK");
43 new_pajeStartLink (MSG_get_clock(), getRootContainer(), type, msg, "M", key);
45 //destroy existing container of this process
46 destroyContainer(getContainer(instr_process_id(process, str, len)));
48 //create new container on the new_host location
49 msg = newContainer(instr_process_id(process, str, len), INSTR_MSG_PROCESS, getContainer(new_host->name));
50 // type = getType (process->category);
51 // new_pajeSetVariable (MSG_get_clock(), msg, type, 1);
53 //set the state of this new container
54 type = getType ("MSG_PROCESS_STATE");
55 new_pajeSetState (MSG_get_clock(), msg, type, "executing");
58 msg = getContainer(instr_process_id(process, str, len));
59 type = getType ("MSG_PROCESS_LINK");
60 new_pajeEndLink (MSG_get_clock(), getRootContainer(), type, msg, "M", key);
64 void TRACE_msg_process_create (m_process_t process)
66 if (TRACE_msg_process_is_enabled()){
67 int len = INSTR_DEFAULT_STR_SIZE;
68 char str[INSTR_DEFAULT_STR_SIZE];
70 m_host_t host = MSG_process_get_host(process);
71 container_t host_container = getContainer(host->name);
72 container_t msg = newContainer(instr_process_id(process, str, len), INSTR_MSG_PROCESS, host_container);
73 // type_t type = getType (category);
75 // type = getVariableType(category, color, msg->type);
77 // new_pajeSetVariable (SIMIX_get_clock(), msg, type, 1);
79 type_t type = getType ("MSG_PROCESS_STATE");
80 new_pajeSetState (MSG_get_clock(), msg, type, "executing");
84 void TRACE_msg_process_kill(m_process_t process)
86 if (TRACE_msg_process_is_enabled()){
87 int len = INSTR_DEFAULT_STR_SIZE;
88 char str[INSTR_DEFAULT_STR_SIZE];
90 //kill means that this process no longer exists, let's destroy it
91 destroyContainer (getContainer(instr_process_id(process, str, len)));
95 void TRACE_msg_process_suspend(m_process_t process)
97 if (TRACE_msg_process_is_enabled()){
98 int len = INSTR_DEFAULT_STR_SIZE;
99 char str[INSTR_DEFAULT_STR_SIZE];
101 container_t process_container = getContainer (instr_process_id(process, str, len));
102 type_t type = getType ("MSG_PROCESS_STATE");
103 new_pajePushState (MSG_get_clock(), process_container, type, "suspend");
107 void TRACE_msg_process_resume(m_process_t process)
109 if (TRACE_msg_process_is_enabled()){
110 int len = INSTR_DEFAULT_STR_SIZE;
111 char str[INSTR_DEFAULT_STR_SIZE];
113 container_t process_container = getContainer (instr_process_id(process, str, len));
114 type_t type = getType ("MSG_PROCESS_STATE");
115 new_pajePopState (MSG_get_clock(), process_container, type);
119 void TRACE_msg_process_sleep_in(m_process_t process)
121 if (TRACE_msg_process_is_enabled()){
122 int len = INSTR_DEFAULT_STR_SIZE;
123 char str[INSTR_DEFAULT_STR_SIZE];
125 container_t process_container = getContainer (instr_process_id(process, str, len));
126 type_t type = getType ("MSG_PROCESS_STATE");
127 new_pajePushState (MSG_get_clock(), process_container, type, "sleep");
131 void TRACE_msg_process_sleep_out(m_process_t process)
133 if (TRACE_msg_process_is_enabled()){
134 int len = INSTR_DEFAULT_STR_SIZE;
135 char str[INSTR_DEFAULT_STR_SIZE];
137 container_t process_container = getContainer (instr_process_id(process, str, len));
138 type_t type = getType ("MSG_PROCESS_STATE");
139 new_pajePopState (MSG_get_clock(), process_container, type);
143 void TRACE_msg_process_end(m_process_t process)
145 if (TRACE_msg_process_is_enabled()) {
146 int len = INSTR_DEFAULT_STR_SIZE;
147 char str[INSTR_DEFAULT_STR_SIZE];
149 //that's the end, let's destroy it
150 destroyContainer (getContainer(instr_process_id(process, str, len)));
154 #endif /* HAVE_TRACING */