| [74e44c5] | 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__));
|
|---|
| 2 | extern void __VERIFIER_assume(int);
|
|---|
| 3 | extern int __VERIFIER_nondet_int();
|
|---|
| 4 |
|
|---|
| 5 | void error(void)
|
|---|
| 6 | {
|
|---|
| 7 |
|
|---|
| 8 | {
|
|---|
| 9 | ERROR: __VERIFIER_error();
|
|---|
| 10 | return;
|
|---|
| 11 | }
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | int q_buf_0 ;
|
|---|
| 15 | int q_free ;
|
|---|
| 16 | int q_read_ev ;
|
|---|
| 17 | int q_write_ev ;
|
|---|
| 18 | int p_num_write ;
|
|---|
| 19 | int p_last_write ;
|
|---|
| 20 | int p_dw_st ;
|
|---|
| 21 | int p_dw_pc ;
|
|---|
| 22 | int p_dw_i ;
|
|---|
| 23 | int c_num_read ;
|
|---|
| 24 | int c_last_read ;
|
|---|
| 25 | int c_dr_st ;
|
|---|
| 26 | int c_dr_pc ;
|
|---|
| 27 | int c_dr_i ;
|
|---|
| 28 | int is_do_write_p_triggered(void)
|
|---|
| 29 | { int __retres1 ;
|
|---|
| 30 |
|
|---|
| 31 | {
|
|---|
| 32 | if ((int )p_dw_pc == 1) {
|
|---|
| 33 | if ((int )q_read_ev == 1) {
|
|---|
| 34 | __retres1 = 1;
|
|---|
| 35 | goto return_label;
|
|---|
| 36 | } else {
|
|---|
| 37 |
|
|---|
| 38 | }
|
|---|
| 39 | } else {
|
|---|
| 40 |
|
|---|
| 41 | }
|
|---|
| 42 | __retres1 = 0;
|
|---|
| 43 | return_label: /* CIL Label */
|
|---|
| 44 | return (__retres1);
|
|---|
| 45 | }
|
|---|
| 46 | }
|
|---|
| 47 | int is_do_read_c_triggered(void)
|
|---|
| 48 | { int __retres1 ;
|
|---|
| 49 |
|
|---|
| 50 | {
|
|---|
| 51 | if ((int )c_dr_pc == 1) {
|
|---|
| 52 | if ((int )q_write_ev == 1) {
|
|---|
| 53 | __retres1 = 1;
|
|---|
| 54 | goto return_label;
|
|---|
| 55 | } else {
|
|---|
| 56 |
|
|---|
| 57 | }
|
|---|
| 58 | } else {
|
|---|
| 59 |
|
|---|
| 60 | }
|
|---|
| 61 | __retres1 = 0;
|
|---|
| 62 | return_label: /* CIL Label */
|
|---|
| 63 | return (__retres1);
|
|---|
| 64 | }
|
|---|
| 65 | }
|
|---|
| 66 | void immediate_notify_threads(void)
|
|---|
| 67 | { int tmp ;
|
|---|
| 68 | int tmp___0 ;
|
|---|
| 69 |
|
|---|
| 70 | {
|
|---|
| 71 | {
|
|---|
| 72 | tmp = is_do_write_p_triggered();
|
|---|
| 73 | }
|
|---|
| 74 | if (tmp) {
|
|---|
| 75 | p_dw_st = 0;
|
|---|
| 76 | } else {
|
|---|
| 77 |
|
|---|
| 78 | }
|
|---|
| 79 | {
|
|---|
| 80 | tmp___0 = is_do_read_c_triggered();
|
|---|
| 81 | }
|
|---|
| 82 | if (tmp___0) {
|
|---|
| 83 | c_dr_st = 0;
|
|---|
| 84 | } else {
|
|---|
| 85 |
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | return;
|
|---|
| 89 | }
|
|---|
| 90 | }
|
|---|
| 91 | void do_write_p(void)
|
|---|
| 92 | {
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 | {
|
|---|
| 96 | if ((int )p_dw_pc == 0) {
|
|---|
| 97 | goto DW_ENTRY;
|
|---|
| 98 | } else {
|
|---|
| 99 | if ((int )p_dw_pc == 1) {
|
|---|
| 100 | goto DW_WAIT_READ;
|
|---|
| 101 | } else {
|
|---|
| 102 |
|
|---|
| 103 | }
|
|---|
| 104 | }
|
|---|
| 105 | DW_ENTRY:
|
|---|
| 106 | {
|
|---|
| 107 | while (1) {
|
|---|
| 108 | while_0_continue: /* CIL Label */ ;
|
|---|
| 109 | if ((int )q_free == 0) {
|
|---|
| 110 | p_dw_st = 2;
|
|---|
| 111 | p_dw_pc = 1;
|
|---|
| 112 |
|
|---|
| 113 | goto return_label;
|
|---|
| 114 | DW_WAIT_READ: ;
|
|---|
| 115 | } else {
|
|---|
| 116 |
|
|---|
| 117 | }
|
|---|
| 118 | {
|
|---|
| 119 | q_buf_0 = __VERIFIER_nondet_int();
|
|---|
| 120 | p_last_write = q_buf_0;
|
|---|
| 121 | p_num_write += 1;
|
|---|
| 122 | q_free = 0;
|
|---|
| 123 | q_write_ev = 1;
|
|---|
| 124 | immediate_notify_threads();
|
|---|
| 125 | q_write_ev = 2;
|
|---|
| 126 | }
|
|---|
| 127 | }
|
|---|
| 128 | while_0_break: /* CIL Label */ ;
|
|---|
| 129 | }
|
|---|
| 130 | return_label: /* CIL Label */
|
|---|
| 131 | return;
|
|---|
| 132 | }
|
|---|
| 133 | }
|
|---|
| 134 | static int a_t ;
|
|---|
| 135 | void do_read_c(void)
|
|---|
| 136 | { int a ;
|
|---|
| 137 |
|
|---|
| 138 | {
|
|---|
| 139 | if ((int )c_dr_pc == 0) {
|
|---|
| 140 | goto DR_ENTRY;
|
|---|
| 141 | } else {
|
|---|
| 142 | if ((int )c_dr_pc == 1) {
|
|---|
| 143 | goto DR_WAIT_WRITE;
|
|---|
| 144 | } else {
|
|---|
| 145 |
|
|---|
| 146 | }
|
|---|
| 147 | }
|
|---|
| 148 | DR_ENTRY:
|
|---|
| 149 | {
|
|---|
| 150 | while (1) {
|
|---|
| 151 | while_1_continue: /* CIL Label */ ;
|
|---|
| 152 | if ((int )q_free == 1) {
|
|---|
| 153 | c_dr_st = 2;
|
|---|
| 154 | c_dr_pc = 1;
|
|---|
| 155 | a_t = a;
|
|---|
| 156 |
|
|---|
| 157 | goto return_label;
|
|---|
| 158 | DR_WAIT_WRITE:
|
|---|
| 159 | a = a_t;
|
|---|
| 160 | } else {
|
|---|
| 161 |
|
|---|
| 162 | }
|
|---|
| 163 | {
|
|---|
| 164 | a = q_buf_0;
|
|---|
| 165 | c_last_read = a;
|
|---|
| 166 | c_num_read += 1;
|
|---|
| 167 | q_free = 1;
|
|---|
| 168 | q_read_ev = 1;
|
|---|
| 169 | immediate_notify_threads();
|
|---|
| 170 | q_read_ev = 2;
|
|---|
| 171 | }
|
|---|
| 172 | if (p_last_write == c_last_read) {
|
|---|
| 173 | if (p_num_write == c_num_read) {
|
|---|
| 174 |
|
|---|
| 175 | } else {
|
|---|
| 176 | {
|
|---|
| 177 | error();
|
|---|
| 178 | }
|
|---|
| 179 | }
|
|---|
| 180 | } else {
|
|---|
| 181 | {
|
|---|
| 182 | error();
|
|---|
| 183 | }
|
|---|
| 184 | }
|
|---|
| 185 | }
|
|---|
| 186 | while_1_break: /* CIL Label */ ;
|
|---|
| 187 | }
|
|---|
| 188 | return_label: /* CIL Label */
|
|---|
| 189 | return;
|
|---|
| 190 | }
|
|---|
| 191 | }
|
|---|
| 192 | void init_threads(void)
|
|---|
| 193 | {
|
|---|
| 194 |
|
|---|
| 195 | {
|
|---|
| 196 | if ((int )p_dw_i == 1) {
|
|---|
| 197 | p_dw_st = 0;
|
|---|
| 198 | } else {
|
|---|
| 199 | p_dw_st = 2;
|
|---|
| 200 | }
|
|---|
| 201 | if ((int )c_dr_i == 1) {
|
|---|
| 202 | c_dr_st = 0;
|
|---|
| 203 | } else {
|
|---|
| 204 | c_dr_st = 2;
|
|---|
| 205 | }
|
|---|
| 206 |
|
|---|
| 207 | return;
|
|---|
| 208 | }
|
|---|
| 209 | }
|
|---|
| 210 | int exists_runnable_thread(void)
|
|---|
| 211 | { int __retres1 ;
|
|---|
| 212 |
|
|---|
| 213 | {
|
|---|
| 214 | if ((int )p_dw_st == 0) {
|
|---|
| 215 | __retres1 = 1;
|
|---|
| 216 | goto return_label;
|
|---|
| 217 | } else {
|
|---|
| 218 | if ((int )c_dr_st == 0) {
|
|---|
| 219 | __retres1 = 1;
|
|---|
| 220 | goto return_label;
|
|---|
| 221 | } else {
|
|---|
| 222 |
|
|---|
| 223 | }
|
|---|
| 224 | }
|
|---|
| 225 | __retres1 = 0;
|
|---|
| 226 | return_label: /* CIL Label */
|
|---|
| 227 | return (__retres1);
|
|---|
| 228 | }
|
|---|
| 229 | }
|
|---|
| 230 | void eval(void)
|
|---|
| 231 | { int tmp ;
|
|---|
| 232 | int tmp___0 ;
|
|---|
| 233 | int tmp___1 ;
|
|---|
| 234 |
|
|---|
| 235 | {
|
|---|
| 236 | {
|
|---|
| 237 | while (1) {
|
|---|
| 238 | while_2_continue: /* CIL Label */ ;
|
|---|
| 239 | {
|
|---|
| 240 | tmp___1 = exists_runnable_thread();
|
|---|
| 241 | }
|
|---|
| 242 | if (tmp___1) {
|
|---|
| 243 |
|
|---|
| 244 | } else {
|
|---|
| 245 | goto while_2_break;
|
|---|
| 246 | }
|
|---|
| 247 | if ((int )p_dw_st == 0) {
|
|---|
| 248 | {
|
|---|
| 249 | tmp = __VERIFIER_nondet_int();
|
|---|
| 250 | }
|
|---|
| 251 | if (tmp) {
|
|---|
| 252 | {
|
|---|
| 253 | p_dw_st = 1;
|
|---|
| 254 | do_write_p();
|
|---|
| 255 | }
|
|---|
| 256 | } else {
|
|---|
| 257 | error();
|
|---|
| 258 | }
|
|---|
| 259 | } else {
|
|---|
| 260 |
|
|---|
| 261 | }
|
|---|
| 262 | if ((int )c_dr_st == 0) {
|
|---|
| 263 | {
|
|---|
| 264 | tmp___0 = __VERIFIER_nondet_int();
|
|---|
| 265 | }
|
|---|
| 266 | if (tmp___0) {
|
|---|
| 267 | {
|
|---|
| 268 | c_dr_st = 1;
|
|---|
| 269 | do_read_c();
|
|---|
| 270 | }
|
|---|
| 271 | } else {
|
|---|
| 272 |
|
|---|
| 273 | }
|
|---|
| 274 | } else {
|
|---|
| 275 |
|
|---|
| 276 | }
|
|---|
| 277 | }
|
|---|
| 278 | while_2_break: /* CIL Label */ ;
|
|---|
| 279 | }
|
|---|
| 280 |
|
|---|
| 281 | return;
|
|---|
| 282 | }
|
|---|
| 283 | }
|
|---|
| 284 | int stop_simulation(void)
|
|---|
| 285 | { int tmp ;
|
|---|
| 286 | int __retres2 ;
|
|---|
| 287 |
|
|---|
| 288 | {
|
|---|
| 289 | {
|
|---|
| 290 | tmp = exists_runnable_thread();
|
|---|
| 291 | }
|
|---|
| 292 | if (tmp) {
|
|---|
| 293 | __retres2 = 0;
|
|---|
| 294 | goto return_label;
|
|---|
| 295 | } else {
|
|---|
| 296 |
|
|---|
| 297 | }
|
|---|
| 298 | __retres2 = 1;
|
|---|
| 299 | return_label: /* CIL Label */
|
|---|
| 300 | return (__retres2);
|
|---|
| 301 | }
|
|---|
| 302 | }
|
|---|
| 303 | void start_simulation(void)
|
|---|
| 304 | { int kernel_st ;
|
|---|
| 305 | int tmp ;
|
|---|
| 306 |
|
|---|
| 307 | {
|
|---|
| 308 | {
|
|---|
| 309 | kernel_st = 0;
|
|---|
| 310 | init_threads();
|
|---|
| 311 | }
|
|---|
| 312 | {
|
|---|
| 313 | int foo = 1;
|
|---|
| 314 | while (foo) {
|
|---|
| 315 | while_3_continue: /* CIL Label */ ;
|
|---|
| 316 | {
|
|---|
| 317 | kernel_st = 1;
|
|---|
| 318 | eval();
|
|---|
| 319 | tmp = stop_simulation();
|
|---|
| 320 | }
|
|---|
| 321 | if (tmp) {
|
|---|
| 322 | goto while_3_break;
|
|---|
| 323 | } else {
|
|---|
| 324 |
|
|---|
| 325 | }
|
|---|
| 326 | }
|
|---|
| 327 | while_3_break: /* CIL Label */ ;
|
|---|
| 328 | }
|
|---|
| 329 |
|
|---|
| 330 | return;
|
|---|
| 331 | }
|
|---|
| 332 | }
|
|---|
| 333 | void init_model(void)
|
|---|
| 334 | {
|
|---|
| 335 |
|
|---|
| 336 | {
|
|---|
| 337 | q_free = 1;
|
|---|
| 338 | q_write_ev = 2;
|
|---|
| 339 | q_read_ev = q_write_ev;
|
|---|
| 340 | p_num_write = 0;
|
|---|
| 341 | p_dw_pc = 0;
|
|---|
| 342 | p_dw_i = 1;
|
|---|
| 343 | c_num_read = 0;
|
|---|
| 344 | c_dr_pc = 0;
|
|---|
| 345 | c_dr_i = 1;
|
|---|
| 346 |
|
|---|
| 347 | return;
|
|---|
| 348 | }
|
|---|
| 349 | }
|
|---|
| 350 | int main(void)
|
|---|
| 351 | { int __retres1 ;
|
|---|
| 352 |
|
|---|
| 353 | {
|
|---|
| 354 | {
|
|---|
| 355 | init_model();
|
|---|
| 356 | start_simulation();
|
|---|
| 357 | }
|
|---|
| 358 | __retres1 = 0;
|
|---|
| 359 | return (__retres1);
|
|---|
| 360 | }
|
|---|
| 361 | }
|
|---|