| 557 | | === Modifying the dependence relation: `$local_start` and `$local_end` |
| 558 | | |
| | 557 | === Specifying local regions: `$local_start` and `$local_end` |
| | 558 | |
| | 559 | CIVL-C provides primitives to constrain the interleaving semantics of a program. |
| | 560 | The program state has a single atomic lock, initially free. |
| | 561 | At any state, if there is a thread ''t'' that owns the atomic lock, only ''t'' is enabled. |
| | 562 | When the atomic lock is free, if there is some thread at a `$local_start` statement, and the first statement following `$local_start` is enabled, |
| | 563 | then among such threads, the thread with lowest ID is the only enabled thread; that thread executes `$local_start` and obtains the lock. |
| | 564 | When ''t'' invokes `$local_end`, ''t'' relinquishes the atomic lock. |
| | 565 | Intuitively, this specifies a block of code to be executed atomically by one thread, and also declares that the block should be treated as a local statement, |
| | 566 | in the sense that it is not necessary to explore all interleavings from the state where the local is enabled. |
| | 567 | |
| | 568 | Local blocks can also be broken up at specified points using function `$yield`. |
| | 569 | If ''t'' owns the atomic lock and calls `$yield`, then ''t'' relinquishes the lock and does not immediately return from the call. |
| | 570 | When the atomic lock is free, there is no thread at a `$local_start`, a thread ''t'' is in a `$yield`, and the first statement following the `$yield` is enabled, |
| | 571 | then ''t'' may return from the `$yield` call and re-obtain the atomic lock. |