Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
494803cd35aaa430422cabbfe84b3f1efe8a541d
[simgrid.git] / src / replay / replay.c
1 /* Specific user API allowing to replay traces without context switches */
2
3 /* Copyright (c) 2010. The SimGrid Team.
4  * All rights reserved.                                                     */
5
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. */
8
9 #include "simgrid_config.h"     /* getline */
10 #include "replay.h"
11 #include "simix/simix.h"
12
13 XBT_LOG_NEW_DEFAULT_CATEGORY(replay,"trace replaying");
14
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;
18
19 static int replay_get_PID(void);
20 static int replay_get_PID(void) {
21   /* FIXME: implement it */
22   return 0;
23 }
24
25 static int replay_wrapper(int argc, char*argv[]) {
26   THROW_UNIMPLEMENTED;
27 }
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);
33
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;
37
38   SIMIX_function_register_default(replay_wrapper);
39 }
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;
42   replay_func_run  =run;
43   replay_func_fini =fini;
44 }
45
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);
50
51   SIMIX_run();
52 }