1 /* Copyright (c) 2009, 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 "simgrid_config.h" //For getline, keep that include first
9 #include "msg_private.h"
11 #include "xbt/dynar.h"
12 #include "xbt/replay.h"
16 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_action, msg,
17 "MSG actions for trace driven simulation");
20 void _MSG_action_init()
22 _xbt_replay_action_init();
23 MSG_function_register_default(xbt_replay_action_runner);
26 void _MSG_action_exit()
28 _xbt_replay_action_exit();
33 /** \ingroup msg_trace_driven
34 * \brief A trace loader
36 * If path!=NULL, load a trace file containing actions, and execute them.
37 * Else, assume that each process gets the path in its deployment file
39 msg_error_t MSG_action_trace_run(char *path)
44 xbt_dict_cursor_t cursor;
48 action_fp = fopen(path, "r");
49 xbt_assert(action_fp != NULL, "Cannot open %s: %s", path,
54 if (!xbt_dict_is_empty(action_queues)) {
56 ("Not all actions got consumed. If the simulation ended successfully (without deadlock), you may want to add new processes to your deployment file.");
59 xbt_dict_foreach(action_queues, cursor, name, todo) {
60 XBT_WARN("Still %lu actions for %s", xbt_dynar_length(todo), name);
66 xbt_dict_free(&action_queues);
67 action_queues = xbt_dict_new_homogeneous(NULL);