2 * @brief Entry point for the model checker.
12 /* global "model" object */
14 #include "snapshot-interface.h"
16 static void param_defaults(struct model_params *params)
19 params->maxfuturedelay = 100;
20 params->fairwindow = 0;
21 params->yieldon = false;
22 params->enabledcount = 1;
24 params->maxfuturevalues = 0;
25 params->expireslop = 10;
26 params->verbose = !!DBG_ENABLED();
29 static void print_usage(struct model_params *params)
31 /* Reset defaults before printing */
32 param_defaults(params);
35 "Usage: <program name> [MC_OPTIONS] -- [PROGRAM ARGUMENTS]\n"
38 "-h Display this help message and exit\n"
39 "-m Maximum times a thread can read from the same write\n"
40 " while other writes exist. Default: %d\n"
41 "-M Maximum number of future values that can be sent to\n"
42 " the same read. Default: %d\n"
43 "-s Maximum actions that the model checker will wait for\n"
44 " a write from the future past the expected number of\n"
45 " actions. Default: %d\n"
46 "-S Future value expiration sloppiness. Default: %u\n"
47 "-f Specify a fairness window in which actions that are\n"
48 " enabled sufficiently many times should receive\n"
49 " priority for execution. Default: %d\n"
50 "-y Turn on CHESS yield-based fairness support.\n"
52 "-e Enabled count. Default: %d\n"
53 "-b Upper length bound. Default: %d\n"
54 "-v Print verbose execution information.\n"
55 "-- Program arguments follow.\n\n",
56 params->maxreads, params->maxfuturevalues, params->maxfuturedelay, params->expireslop, params->fairwindow, params->yieldon, params->enabledcount, params->bound);
60 static void parse_options(struct model_params *params, int argc, char **argv)
62 const char *shortopts = "hym:M:s:S:f:e:b:v";
65 while (!error && (opt = getopt(argc, argv, shortopts)) != -1) {
71 params->maxfuturedelay = atoi(optarg);
74 params->expireslop = atoi(optarg);
77 params->fairwindow = atoi(optarg);
80 params->enabledcount = atoi(optarg);
83 params->bound = atoi(optarg);
86 params->maxreads = atoi(optarg);
89 params->maxfuturevalues = atoi(optarg);
95 params->yieldon = true;
103 /* Pass remaining arguments to user program */
104 params->argc = argc - (optind - 1);
105 params->argv = argv + (optind - 1);
107 /* Reset program name */
108 params->argv[0] = argv[0];
110 /* Reset (global) optind for potential use by user program */
120 /** The model_main function contains the main model checking loop. */
121 static void model_main()
123 struct model_params params;
125 param_defaults(¶ms);
127 parse_options(¶ms, main_argc, main_argv);
129 //Initialize race detector
132 snapshot_stack_init();
134 model = new ModelChecker(params);
143 * Main function. Just initializes snapshotting library and the
144 * snapshotting library calls the model_main function.
146 int main(int argc, char **argv)
151 /* Configure output redirection for the model-checker */
154 /* Let's jump in quickly and start running stuff */
155 snapshot_system_init(10000, 1024, 1024, 4000, &model_main);