next up previous
Next: REL takes a message Up: INSTRUCTIONS Previous: OUTG writes variable and

PREEMPTION allows a message to preempt another that is using the resource

Syntax:

    PREEMPTION(<logical expression> / ,REMA / ) <associated instruction>;
This instruction is used to remove a message that is occupying a resource represented by a R type node of size 1 with a STAY instruction. It may be used only in a R type node of capacity 1, but not in the RELEASE instruction. It is executed when some message is in the EL and it is examined. When executed, the IL is checked. If it is void, the message enters the IL and nothing more is done. If it is not free, then the fields of the message in the IL are passed to the corresponding O_<fields> and the <logical expression> is evaluated. If it is FALSE, the examined message remains in the EL and nothing more is done. If it is TRUE, then the occupying message is removed from the IL and the new message occupies the resource (enters the IL). When this preemption process happens, the <associated instruction> is executed. The preempted message is disposed by a SENDTO instruction that must be in the <associated instruction>. This instruction may change the fields of the preempted message before the SENDTO is executed. If the option REMA is present, the preempted message must have a REAL field called REMA that the user must define and initialize to zero. Then the remaining time (time that the preempted message would yet remain in the IL) is stored into the field REMA. When this message regains the resource with its REMA field different from zero, then the time that has to remain in the IL is taken from the REMA instead of using the one indicated by the instruction STAY. This value might have previously been changed in the <associated instruction>. The REMA field is automatically put to zero when the message regains the resource.

The <logical expression> may have global variables, local variables, field variables of the examined messages and O_<fields> of the occupant message. Note that if the removed message has a field REMA and, instead of regaining the node from which it was removed, it enters another R node, the time to remain there would be taken from the REMA and not from the STAY of this node, unless the REMA were explicitly put to zero.

PREEMPTION can only be used in the non RELEASE part of the code of an R type node of capacity 1 and before the STAY instruction.

Example:

Messages (patients) that arrive at Hospital have a Disease
 type and a Status of seriousness. The Critical are put at the
 beginning of the queue for Diagnostic. In Diagnostic a Critical
 can remove a non Critical from attention. The removed is sent
 at the beginning of the queue. Its future time of attention is the
 remaining time increased 20%. After the Diagnostic the messages
 are sent to one node of the multiple node Treatment according to
 their Disease.
 Note the declaration and initialization of the field REMA.
 One defect of the program: if one Critical is in the IL and two
 other Critical arrive, then they will be put in the queue (EL) in
 reverse order. See instruction SCAN (6.21) for a solution.
 Note that it is also unrealistic that the variables Status
 and Disease were uncorrelated+. See RAND function (8.25) for a solution.

 NETWORK
   ---------------------------------------------------
   Patient   (I) :: IT := EXPO(5.5); Disease := Fdisease;
                    Status := Fstatus; REMA := 0;

   Hospital  (G) :: IF Status = Critical THEN SENDTO(FIRST, Diagnostic)
                                      ELSE SENDTO(Diagnostic);

   Diagnostic (R) Diagnostic, Treatment[INO] ::

       RELEASE BEGIN Disn := Ord(Disease); SENDTO(Treatment[Dis]) END;
       PREEMPTION((Status = Critical) AND (O_Status < Critical), REMA)
          BEGIN REMA := REMA * 1.2; SENDTO(FIRST, Diagnostic) END;
       STAY := GAMMA(MDiag, DDiag);
   -----------------------------------------------------
   INIT
   Fdisease := Hurt,15 / Infectous,20 / Shock,25 / Hearth,30 / Internal,20;
   Fstatus := Non_Serious, 30 / Medium, 40 / Serious, 30 / Critical, 20;
   -----------------------------------------------------
   DECL TYPE St = (Non_Serious, Medium, Serious,  Critical);
             Dis = (Hurt, Infectious, Shock, Heart, Internal);
        MESSAGES Patient(Disease: Dis; Status: St; REMA: REAL);
        GFUNCTIONS
         Fdisease FREQ (Dis): REAL: 5;
         Fstatus  FREQ (St): REAL: 4;
See example 8 (GLIDER examples book).


next up previous
Next: REL takes a message Up: INSTRUCTIONS Previous: OUTG writes variable and

domingo c
Mon Mar 20 17:36:19 PST 2000