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/private.h"
11 static xbt_dict_t process_containers = NULL;
13 void TRACE_msg_process_alloc(void)
15 process_containers = xbt_dict_new();
18 void TRACE_msg_process_release(void)
20 xbt_dict_free(&process_containers);
23 static void TRACE_msg_process_location(m_process_t process)
25 char name[200], alias[200];
27 if (!(IS_TRACING_PROCESSES || IS_TRACING_VOLUME))
30 host = MSG_process_get_host(process);
31 TRACE_process_container(process, name, 200);
32 TRACE_process_alias_container(process, host, alias, 200);
34 //check if process_alias container is already created
35 if (!xbt_dict_get_or_null(process_containers, alias)) {
36 pajeCreateContainer(MSG_get_clock(), alias, "PROCESS",
37 MSG_host_get_name(host), name);
38 if (IS_TRACING_PROCESSES)
39 pajeSetState(MSG_get_clock(), "category", alias, process->category);
40 xbt_dict_set(process_containers, xbt_strdup(alias), xbt_strdup("1"),
45 static void TRACE_msg_process_present(m_process_t process)
49 if (!IS_TRACING_PROCESSES)
52 //updating presence state of this process location
53 host = MSG_process_get_host(process);
54 TRACE_process_alias_container(process, host, alias, 200);
55 pajePushState(MSG_get_clock(), "presence", alias, "presence");
59 * TRACE_msg_set_process_category: tracing interface function
61 void TRACE_msg_set_process_category(m_process_t process,
68 //set process category
69 process->category = xbt_strdup(category);
71 //create container of type "PROCESS" to indicate location
72 TRACE_msg_process_location(process);
73 TRACE_msg_process_present(process);
75 //create container of type "process" to indicate behavior
76 TRACE_process_container(process, name, 200);
77 if (IS_TRACING_PROCESSES)
78 pajeCreateContainer(MSG_get_clock(), name, "process", category, name);
79 if (IS_TRACING_PROCESSES)
80 pajeSetState(MSG_get_clock(), "process-state", name, "executing");
84 * Instrumentation functions to trace MSG processes (m_process_t)
86 void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host,
90 if (!(IS_TRACING_PROCESSES || IS_TRACING_VOLUME) || !IS_TRACED(process))
93 //disabling presence in old_host (__TRACE_msg_process_not_present)
94 TRACE_process_alias_container(process, old_host, alias, 200);
95 if (IS_TRACING_PROCESSES)
96 pajePopState(MSG_get_clock(), "presence", alias);
98 TRACE_msg_process_location(process);
99 TRACE_msg_process_present(process);
102 void TRACE_msg_process_kill(m_process_t process)
105 if (!IS_TRACING_PROCESSES || !IS_TRACED(process))
108 TRACE_process_container(process, name, 200);
109 pajeDestroyContainer(MSG_get_clock(), "process", name);
112 void TRACE_msg_process_suspend(m_process_t process)
115 if (!IS_TRACING_PROCESSES || !IS_TRACED(process))
118 TRACE_process_container(process, name, 200);
119 pajeSetState(MSG_get_clock(), "process-state", name, "suspend");
122 void TRACE_msg_process_resume(m_process_t process)
125 if (!IS_TRACING_PROCESSES || !IS_TRACED(process))
128 TRACE_process_container(process, name, 200);
129 pajeSetState(MSG_get_clock(), "process-state", name, "executing");
132 void TRACE_msg_process_sleep_in(m_process_t process)
135 if (!IS_TRACING_PROCESSES || !IS_TRACED(process))
138 TRACE_process_container(process, name, 200);
139 pajeSetState(MSG_get_clock(), "process-state", name, "sleep");
142 void TRACE_msg_process_sleep_out(m_process_t process)
145 if (!IS_TRACING_PROCESSES || !IS_TRACED(process))
148 TRACE_process_container(process, name, 200);
149 pajeSetState(MSG_get_clock(), "process-state", name, "executing");
152 void TRACE_msg_process_end(m_process_t process)
154 char name[200], alias[200];
155 m_host_t host = NULL;
156 if (!IS_TRACED(process))
159 host = MSG_process_get_host(process);
160 TRACE_process_container(process, name, 200);
161 TRACE_process_alias_container(process, host, alias, 200);
162 if (IS_TRACING_PROCESSES)
163 pajeDestroyContainer(MSG_get_clock(), "process", name);
164 if (IS_TRACING_PROCESSES)
165 pajeDestroyContainer(MSG_get_clock(), "PROCESS", alias);