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"
14 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_action, msg,
15 "MSG actions for trace driven simulation");
18 void _MSG_action_init()
20 _xbt_replay_action_init();
21 MSG_function_register_default(xbt_replay_action_runner);
24 void _MSG_action_exit()
26 _xbt_replay_action_exit();
31 /** \ingroup msg_trace_driven
32 * \brief A trace loader
34 * If path!=NULL, load a trace file containing actions, and execute them.
35 * Else, assume that each process gets the path in its deployment file
37 MSG_error_t MSG_action_trace_run(char *path)
42 xbt_dict_cursor_t cursor;
46 action_fp = fopen(path, "r");
47 xbt_assert(action_fp != NULL, "Cannot open %s: %s", path,
52 if (!xbt_dict_is_empty(action_queues)) {
54 ("Not all actions got consumed. If the simulation ended successfully (without deadlock), you may want to add new processes to your deployment file.");
57 xbt_dict_foreach(action_queues, cursor, name, todo) {
58 XBT_WARN("Still %lu actions for %s", xbt_dynar_length(todo), name);
64 xbt_dict_free(&action_queues);
65 action_queues = xbt_dict_new_homogeneous(NULL);