5.6 Concurrency primitives

qBeta has the following concurrency primitives:

  1. R.suspend
  2. R.attach
  3. R.attach(exp)
  4. R.resume
  5. M.cmpAndSwap(exp) where M is an integer
  6. fork(R)

We need to describe pattern Core representing physical cores. Perhaps in the section on active objects?

Suspend

R.suspend implies that execution of the object R is suspended and control returns to the caller of R.

R must be an object on the execution stack.

Cooperative attach

R.attach implies that execution of the object R is resumed at the latest point of suspend or if never executed, at the start of its statements.

Preemptive attach

R.attach(exp) implies that execution of the object R is resumed at the latest point of suspend or if never executed, at the start of its statements.

The expression exp must evaluate to an integer value.

R is preemptively suspended after exp time units.

Resume

R.resumedo we still have this one?

CmpAndSwap

M.cmpAndSwap(exp) implies that the value of exp is attempted to be assigned to M. The expression exp must evaluate to an integer value.

CmpAndSwap is similar to the machine instructions available on many CPUs. A description will be supplied.

Fork

Fork(R) implies that the object R is attached to a Core-object representing a physical core.

Grammar

<Concurrency-Primitives> ::= <Suspend>
                          | <Cooperative-Attach>
                          | <Preemptive-Attach> 
                          |  <Resume> | <CmpAndSwap> | <Fork>
<Suspend> ::= <Object-Denotation> '.' 'suspend'
<Cooperative-Attach> ::= <Object-Denotation>  '.' 'attach'
<Preemptive-Attach> ::= <Object-Denotation>  '.' 'attach' '(' <Integer-Evaluation> ')'
<Resume> ::= <Object-Denotation>  '.' 'resume'
<CmpAndSwap> ::= <Integer-Object-Denotation>  '.' 'CmpAndSwap' '(' <Integer-Evaluation> ')'
<Fork> ::= 'fork' '(' <Object-Denotation> ')'

Hello world