Changes between Version 26 and Version 27 of Language


Ignore:
Timestamp:
05/19/23 20:51:05 (3 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Language

    v26 v27  
    605605In 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".
    606606
     607==== Example
     608
     609The code
     610{{{
     611  $local_start();
     612  ...A...
     613  $local_end();
     614  $local_start();
     615  ...B...
     616  $local_end()
     617}
     618int main() {
     619  $parfor (int i:1..2) thread(i);
     620}
     621}}}
     622also has only one execution.
     623Thread 1 will execute local block A and then release the atomic lock.
     624But 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.
     625It will execute local block B, and only then will thread 2 execute.
     626The code above is equivalent to
     627{{{
     628 $local_start();
     629  ...A...
     630  ...B...
     631  $local_end()
     632}
     633int main() {
     634  $parfor (int i:1..2) thread(i);
     635}
     636}}}
     637
    607638==== Use of `$yield` within a local region
    608639
     
    612643then ''t'' may return from the `$yield` call and re-obtain the atomic lock.
    613644
     645Note that a thread waiting to return from a `$yield` has no special priority, even if that `$yield` is inside at local region.
     646Only `$local_start` grants a thread a special priority.
     647This is illustrated in the following example.
     648
     649==== Example
     650
     651
     652
    614653=== Heap memory allocation: `$malloc` and `$free`
    615654