Home    Reference > C Tags > @x:exclude
prev next

Description

This command is used for mutual exclusion and monitors based on a lock.

Command Syntax

'@x:exclude' <exp>

No options are permitted.

Execution Semantics

The expression is evaluated and the result must have type lock. If the lock is locked, execution of the current thread waits until the lock is unlocked. If the lock is unlocked, then it is locked and the body is executed. After the end of body execution the lock is unlocked. Calling lock operations within the body can be used to make the @x:exclude command operate as a monitor.

Examples


   @x:type counter;
   @x:self {
      @x:var val := 0;
      @x:var lock1 := lock;
      @x:func incr(),visible {
         @x:exclude lock1 {
            val := val + 1
         }
      }
      @x:func decr(),visible {
         @x:exclude lock1 {
            val := val - 1
         }
      }
   }

The queue example shows the use of monitors.