Changes between Version 26 and Version 27 of Language
- Timestamp:
- 05/19/23 20:51:05 (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Language
v26 v27 605 605 In this program, the threads write to `x` within a local region. This program has only one execution: first thread 1 executes the complete local region, then thread 2 executes the complete local region. Running `civl verify` on this code yields "all properties hold". 606 606 607 ==== Example 608 609 The code 610 {{{ 611 $local_start(); 612 ...A... 613 $local_end(); 614 $local_start(); 615 ...B... 616 $local_end() 617 } 618 int main() { 619 $parfor (int i:1..2) thread(i); 620 } 621 }}} 622 also has only one execution. 623 Thread 1 will execute local block A and then release the atomic lock. 624 But at that point, thread 1 will again be the thread of lowest PID at a `$local_start()` and therefore will be the only enabled thread. 625 It will execute local block B, and only then will thread 2 execute. 626 The code above is equivalent to 627 {{{ 628 $local_start(); 629 ...A... 630 ...B... 631 $local_end() 632 } 633 int main() { 634 $parfor (int i:1..2) thread(i); 635 } 636 }}} 637 607 638 ==== Use of `$yield` within a local region 608 639 … … 612 643 then ''t'' may return from the `$yield` call and re-obtain the atomic lock. 613 644 645 Note that a thread waiting to return from a `$yield` has no special priority, even if that `$yield` is inside at local region. 646 Only `$local_start` grants a thread a special priority. 647 This is illustrated in the following example. 648 649 ==== Example 650 651 652 614 653 === Heap memory allocation: `$malloc` and `$free` 615 654
