Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MSG_task_isend_internal: remove unused parameters match_fun and match_data.
[simgrid.git] / src / msg / instr_msg_process.cpp
1 /* Copyright (c) 2010, 2012-2017. The SimGrid Team. All rights reserved.    */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "simgrid/s4u/Host.hpp"
7 #include "src/instr/instr_private.hpp"
8 #include "src/msg/msg_private.hpp"
9 #include "src/simix/ActorImpl.hpp"
10 #include <simgrid/actor.h>
11
12 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_msg_process, instr, "MSG process");
13
14 std::string instr_pid(msg_process_t proc)
15 {
16   return std::string(proc->getCname()) + "-" + std::to_string(proc->getPid());
17 }
18
19 void TRACE_msg_process_change_host(msg_process_t process, msg_host_t new_host)
20 {
21   if (TRACE_actor_is_enabled()) {
22     static long long int counter = 0;
23
24     std::string key = std::to_string(counter);
25     counter++;
26
27     //start link
28     container_t msg                = simgrid::instr::Container::byName(instr_pid(process));
29     simgrid::instr::LinkType* link = simgrid::instr::Container::getRoot()->getLink("MSG_PROCESS_LINK");
30     link->startEvent(msg, "M", key);
31
32     //destroy existing container of this process
33     TRACE_msg_process_destroy(process);
34
35     //create new container on the new_host location
36     TRACE_msg_process_create(process, new_host);
37
38     //end link
39     msg = simgrid::instr::Container::byName(instr_pid(process));
40     link->endEvent(msg, "M", key);
41   }
42 }
43
44 void TRACE_msg_process_create(msg_process_t process, msg_host_t host)
45 {
46   if (TRACE_actor_is_enabled()) {
47     container_t host_container = simgrid::instr::Container::byName(host->getName());
48     new simgrid::instr::Container(instr_pid(process), "MSG_PROCESS", host_container);
49   }
50 }
51
52 void TRACE_msg_process_destroy(msg_process_t process)
53 {
54   if (TRACE_actor_is_enabled()) {
55     container_t container = simgrid::instr::Container::byNameOrNull(instr_pid(process));
56     if (container) {
57       container->removeFromParent();
58       delete container;
59     }
60   }
61 }
62
63 void TRACE_msg_process_kill(smx_process_exit_status_t status, msg_process_t process)
64 {
65   if (TRACE_actor_is_enabled() && status == SMX_EXIT_FAILURE) {
66     //kill means that this process no longer exists, let's destroy it
67     TRACE_msg_process_destroy(process);
68   }
69 }