model: make scheduler private
[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         ucontext_t main_context;
25         struct model_params params;
26
27         parse_options(&params, main_argc, main_argv);
28
29         //Initialize race detector
30         initRaceDetector();
31
32         //Create the singleton SnapshotStack object
33         snapshotObject = new SnapshotStack();
34
35         model = new ModelChecker(params);
36
37         if (getcontext(&main_context))
38                 return;
39
40         model->set_system_context(&main_context);
41
42         snapshotObject->snapshotStep(0);
43         do {
44                 /* Start user program */
45                 model->add_thread(new Thread(&user_thread, (void (*)(void *)) &user_main, NULL));
46
47                 /* Wait for all threads to complete */
48                 model->finish_execution();
49         } while (model->next_execution());
50
51         delete model;
52
53         DEBUG("Exiting\n");
54 }
55
56 /**
57  * Main function.  Just initializes snapshotting library and the
58  * snapshotting library calls the real_main function.
59  */
60 int main(int argc, char ** argv) {
61         main_argc = argc;
62         main_argv = argv;
63
64         /* Let's jump in quickly and start running stuff */
65         initSnapShotLibrary(10000, 1024, 1024, 1000, &real_main);
66 }