2 * @brief Entry point for the model checker.
7 #include "libthreads.h"
13 /* global "model" object */
15 #include "snapshot-interface.h"
17 static void param_defaults(struct model_params * params) {
21 static void print_usage() {
23 "Usage: <program name> [MC_OPTIONS] -- [PROGRAM ARGUMENTS]\n"
26 "-h Display this help message and exit\n"
27 "-m Maximum times a thread can read from the same write while other writes exist\n"
28 "-- Program arguments follow.\n\n");
32 static void parse_options(struct model_params *params, int *argc, char ***argv) {
33 const char *shortopts = "hm:";
36 while (!error && (opt = getopt(*argc, *argv, shortopts)) != -1) {
42 params->maxreads = atoi(optarg);
59 /** The real_main function contains the main model checking loop. */
60 static void real_main() {
62 struct model_params params;
64 param_defaults(¶ms);
66 parse_options(¶ms, &main_argc, &main_argv);
68 //Initialize race detector
71 //Create the singleton SnapshotStack object
72 snapshotObject = new SnapshotStack();
74 model = new ModelChecker(params);
76 snapshotObject->snapshotStep(0);
78 /* Start user program */
79 model->add_thread(new Thread(&user_thread, (void (*)(void *)) &user_main, NULL));
81 /* Wait for all threads to complete */
82 model->finish_execution();
83 } while (model->next_execution());
91 * Main function. Just initializes snapshotting library and the
92 * snapshotting library calls the real_main function.
94 int main(int argc, char ** argv) {
98 /* Let's jump in quickly and start running stuff */
99 initSnapShotLibrary(10000, 1024, 1024, 1000, &real_main);