next up previous
Next: LIFO puts the message Up: PROCEDURES Previous: FIFO puts the message

FREE frees a resource

Syntax:

    FREE(<node name>);
It is used to release a resource from the R type node that was left by the message without releasing the resource at the leaving time (see NOTFREE procedure, 7.14). The quantity of resource freed from the indicated node is equal to the actual value of the USE variable. The procedure may be executed in any node when processing any message or no message at all. However, in most usual applications, it is executed while processing the message that left the resource without releasing the used capacity. In many applications the message has to do other things, or await certain time, before the abandoned resource become available.

This procedure can be used in nodes of any type.

Example:

    Crane (R) Return, ProcLoad, Command::
        RELEASE
        IF HeapSize > 0 THEN BEGIN NOTFREE; SENDTO(Return, ProcLoad) END
                                   ELSE SENDTO(Command, ProcLoad);
        IF F_Crane >= 1 THEN
                             BEGIN
                                  STAY := GAMMA(MTCrane, DevTCrane);
                                  LoadCrane := MINI(HeapSize, UNIFI(2, 3));
                                  HeapSize := HeapSize - LoadCrane;
                             END;
     Return (R) Crane::
         RELEASE BEGIN FREE(Crane); SENDTO(FIRST, Crane) END;
         STAY := ReturnTime + TRIA(1, 2, 4);
A crane have to remove a heap of packages that may be transported in groups that have, at random with the same probability, 2 or 3 packages. The time to handle and transport the load is taken from a GAMMA distribution. When the heap is reduced to zero, the process finishes and the crane is available to transport another heap when that is commanded. If the remaining heap is not zero, the crane have to return to continue the removal. The crane is not available during this period. Continuation of the process has priority over any other new process of heap transportation.
Crane operation is simulated by a node Crane of capacity 1. It is activated by a message that represents the order to operate. This messages can queue in the EL of Crane. The message has a field HeapSize with the size of the heap to be removed and a field LoadCrane to keep the transported quantity. When the message is processed the LoadCrane is computed (all the heap or 2 or 3) and the time delay in loading and transport is taken into account. When this process finishes the message is sent to ProcLoad to process the actual load. If the heap is not empty, a copy is sent to a node Return to account for the delay to return near the heap. Otherwise, the copy is sent to Command that decides about new command messages to remove heaps. In the Return node the message is delayed a time for the return and then sent to the Crane again, before other commands, to continue the heap removal.
Notice the condition IF F_Crane = 0 to avoid execution of instructions without transfer of the message to the IL.


next up previous
Next: LIFO puts the message Up: PROCEDURES Previous: FIFO puts the message

domingo c
Mon Mar 20 17:37:52 PST 2000