1 /* Copyright (c) 2009-2015. 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 "msg_private.h"
9 #include "xbt/replay.h"
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_action, msg, "MSG actions for trace driven simulation");
15 void MSG_action_init()
17 _xbt_replay_action_init();
18 MSG_function_register_default(xbt_replay_action_runner);
21 void MSG_action_exit()
23 _xbt_replay_action_exit();
26 /** \ingroup msg_trace_driven
27 * \brief A trace loader
29 * If path!=nullptr, load a trace file containing actions, and execute them.
30 * Else, assume that each process gets the path in its deployment file
32 msg_error_t MSG_action_trace_run(char *path)
37 xbt_dict_cursor_t cursor;
39 xbt_action_fp=nullptr;
41 xbt_action_fp = fopen(path, "r");
42 xbt_assert(xbt_action_fp != nullptr, "Cannot open %s: %s", path, strerror(errno));
46 if (!xbt_dict_is_empty(xbt_action_queues)) {
47 XBT_WARN("Not all actions got consumed. If the simulation ended successfully (without deadlock),"
48 " you may want to add new processes to your deployment file.");
50 xbt_dict_foreach(xbt_action_queues, cursor, name, todo) {
51 XBT_WARN("Still %lu actions for %s", xbt_dynar_length(todo), name);
56 fclose(xbt_action_fp);
57 xbt_dict_free(&xbt_action_queues);
58 xbt_action_queues = xbt_dict_new_homogeneous(nullptr);