model: rename 'cyclegraph' to 'mo_graph'
[model-checker.git] / main.cc
1 /** @file main.cc
2  *  @brief Entry point for the model checker.
3  */
4
5 #include "libthreads.h"
6 #include "common.h"
7 #include "threads.h"
8
9 #include "datarace.h"
10
11 /* global "model" object */
12 #include "model.h"
13 #include "snapshot-interface.h"
14
15 static void parse_options(struct model_params *params, int argc, char **argv) {
16 }
17
18 int main_argc;
19 char **main_argv;
20
21 /** The real_main function contains the main model checking loop. */
22 static void real_main() {
23         thrd_t user_thread;
24         struct model_params params;
25
26         parse_options(&params, main_argc, main_argv);
27
28         //Initialize race detector
29         initRaceDetector();
30
31         //Create the singleton SnapshotStack object
32         snapshotObject = new SnapshotStack();
33
34         model = new ModelChecker(params);
35
36         snapshotObject->snapshotStep(0);
37         do {
38                 /* Start user program */
39                 model->add_thread(new Thread(&user_thread, (void (*)(void *)) &user_main, NULL));
40
41                 /* Wait for all threads to complete */
42                 model->finish_execution();
43         } while (model->next_execution());
44
45         delete model;
46
47         DEBUG("Exiting\n");
48 }
49
50 /**
51  * Main function.  Just initializes snapshotting library and the
52  * snapshotting library calls the real_main function.
53  */
54 int main(int argc, char ** argv) {
55         main_argc = argc;
56         main_argv = argv;
57
58         /* Let's jump in quickly and start running stuff */
59         initSnapShotLibrary(10000, 1024, 1024, 1000, &real_main);
60 }