1 /* Specific user API allowing to replay traces without context switches */
3 /* Copyright (c) 2010. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
9 #include "simgrid_config.h" /* getline */
11 #include "simix/simix.h"
13 XBT_LOG_NEW_DEFAULT_CATEGORY(replay,"trace replaying");
15 replay_init_func_t replay_func_init=NULL;
16 replay_run_func_t replay_func_run=NULL;
17 replay_fini_func_t replay_func_fini=NULL;
19 static int replay_get_PID(void);
20 static int replay_get_PID(void) {
21 /* FIXME: implement it */
25 static int replay_wrapper(int argc, char*argv[]) {
28 /** \brief initialize the replay mechanism */
29 void SG_replay_init(int *argc, char **argv) {
30 factory_initializer_to_use = statem_factory_init;
31 xbt_getpid = replay_get_PID;
32 SIMIX_global_init(argc, argv);
34 /* Restore the default exception handlers: we have no real processes */
35 __xbt_running_ctx_fetch = &__xbt_ex_ctx_default;
36 __xbt_ex_terminate = &__xbt_ex_terminate_default;
38 SIMIX_function_register_default(replay_wrapper);
40 void SG_replay_set_functions(replay_init_func_t init, replay_run_func_t run,replay_fini_func_t fini) {
41 replay_func_init =init;
43 replay_func_fini =fini;
46 /** \brief Loads a platform and deployment from the given file. Trace must be loaded from deployment */
47 void SG_replay(const char *environment_file, const char *deploy_file) {
48 SIMIX_create_environment(environment_file);
49 SIMIX_launch_application(deploy_file);