There is a built-in priority scheduler. Elaboration of all task activations whose activation variables
have type ACT is controlled by this scheduler. This section discusses the high-level operations for the
ACT scheduler. Low-level ACT operations are discussed in Section 14. Techniques for defining other
schedulers are discussed in Section 14.5.
The result of the ME function is the activation variable of the activation that invokes ME.
Scheduling of task activations whose activation variables have type ACT is determined based on
priorities. Each activation has a priority which is an integer with subtype
Priority 0 is the lowest priority (the priority least likely to be scheduled) and priority 255 is the
highest priority (the priority most likely to be scheduled). The priority of an activation, av, can be
obtained by invoking the function
whose result is the priority of av.
The priority of any activation, av, can be set to value n by invoking the procedure
The initial priority of the main activation of a program is set by the user when the program is to
be run. If no priority has been explicitly set, the initial priority of other activations is equal to the
current priority of the activating activation.
Elaboration of the procedure invocation
will cause the X_TERMINATE exception to be raised in the activation currently associated with
activation variable a. The invocation has no effect if a is inactive. If a is waiting, then it becomes
eligible to run.
At any time, there will be some activations which are eligible to run. The ACT scheduling
algorithm decides which of the activations are to be run. The language makes no assumptions about
the number of activations which can be run concurrently. On some target systems, at most one
activation will be running, while on other systems, several activations can be running concurrently.
For the set of activations which are eligible to run, an activation with a higher priority will be
scheduled before an activation with a lower priority and, for activations having the same priority,
those activations which have been eligible for the longest time will be scheduled over the other
ME, PRIORITY, SET_PRIORITY, and EXTERMINATE are described in detail under the ACT type in Appendix C.10.
The scheduling algorithm is described in detail in Section 14.2.
- Setting priorities
10.3 MESSAGE PASSING USING MAILBOX VARIABLES
Message passing is done via mailboxes. Activations can send messages to a mailbox, and other
activations can then receive these messages from the mailbox. A mailbox ls a variable having a
mailbox type. For example,
VAR m : MAILBOX[ STRING[ASCII](4) ] (3);
Here, m is a mailbox of size 3 capable of holding messages, each having the subtype
STRING[A5CII](4). The size specifies that at any time up to 3 messages could have been sent but
not yet received.
A mailbox is initially empty (i.e. holds no messages). The SEND procedure is used to send a
message to a mailbox. For example,
sends the message "MES1" to mailbox m. Additional messages can be sent to m by additional sends.
The RECEIVE procedure is used to receive a message from a mailbox. For example,
VAR v : STRING[ASCII] (4);
will place the next available message from mailbox m into variable v. Messages are stored in a mailbox
in order of arrival so that the first message to be received from a mailbox will be the first message
sent to the mailbox. In the above example, the value of v after invoking RECEIVE would be "MESI".
When a mailbox becomes full, no more messages can be sent. If an attempt is made to send a
message to a full mailbox, then the sender will wait until the mailbox is no longer full. If there is more
than one activation waiting as a result of attempting to send a message to a full mailbox, these
senders are queued in the order in which the sends were done. The first sender will therefore be the
first to complete the send. A similar queueing occurs when receives are attempted on an empty
Mailboxes_with Size 0
When the size of a mailbox is 0, the sender can never get ahead of the receiver. For example,
VAR m1 : MAILBOX[ STRING[ASCII](4) ] (0);
In this case, the SEND(m1, "ABCD") will wail unless there is some receive request outstanding. In
this latter case, SEND(m1, "ABCD") will send the message "ABCD" directly to the requesting
Messages sent to a mailbox and received from that mailbox are handled on a first in (i.e., first sent
to the mailbox) first out (i.e., first received from the mailbox) basis. In particular, the i'th receive wlll
get the message from the i'th send.
returns the value of the real-time clock in ticks. The function
An activation can be delayed until the value of the real-time clock is t by elaborating
An activation can be delayed until the value of the activation clock for activation a has the value t by