If a block is invoked during a sweep, NOL evaluates the block on the current sweep. If a block is invoked when no sweep is in progress, NOL evaluates the block on the next sweep. The important thing to note is that block invocation happens independently of block evaluation.
If a block located on the subworkspace of an encapsulation is invoked, NOL invokes the encapsulation block, and any superior encapsulations, until all the invocations are on workspaces that contain blocks other than encapsulation block subworkspaces.
NOL performs three types of sweeps:
You can control the frequency of entry point sweeps in the Environment Settings under the Preferences menu. By default, entry point sweeps happen once every second. For more information, see "Setting the Sweep Interval".
Sweeping Diagrams Based on Events
Certainevents cause NOL to begin a sweep immediately. These events include:
All clocks and signal generators scheduled to fire within the same quarter-second are grouped together into the same sweep.
evaluate menu choice or by
using the override menu choice, a manual sweep happens immediately.
Manual invocations are never mixed with other types of invocations, because typically each manual invocation is associated with a specific G2 window. Each override or manual evaluation results in a manual sweep, which is handled separately from any other scheduled activities.
If such a workspace has an invocation, NOL sweeps the workspace in the order described in "Evaluating Blocks on Individual Workspaces". Blocks that have an invocation evaluate, which might lead to the invocation of other blocks, which are also evaluated in the current sweep.
When an encapsulation block evaluates, NOL sweeps its subworkspace. When
NOL is finished sweeping the subworkspace, evaluation returns to the superior
workspace.
Evaluating Blocks on Individual Workspaces
To understand the order of evaluation of blocks on an individual workspace, you
can think of each block on a workspace as having a number, which is the order in
which NOL checks for invocations on the workspace.
queue or ok, in which case the block
can evaluate more than once per sweep.
|
This diagram shows how NOL numbers blocks on a diagram that contains a block
with multiple inputs, in this example, block D:
|
Inside of feedback loops, no upstream/downstream relationships exist, thus
feedback loops are numbered in two steps. First, the blocks in the loop are
numbered via a depth-first search, according to the explanation above. Next,
NOL backs up to the block that begins the loop and "promotes" the blocks in the
loop so that they appear consecutively in the list, without changing their relative
order. In this way, the loop processes until it is finished before the downstream
blocks evaluate. When a diagram contains nested loops, the same "promotion"
process assures that the inner loop finishes evaluating before each evaluation of
the outer loop.
|
When blocks evaluate, an "evaluation pointer" advances from block to block,
following the serial numbering of blocks in ascending order. If the pointer arrives
at an invoked block, the block evaluates. If the pointer arrives at a block that has
not been invoked, the pointer moves to the next block. The only time the pointer
moves back in the series is when there is a path from a high-numbered block to a
low-numbered block, at which point evaluation returns to the low-numbered
block only if it has a pending invocation. Evaluation then continues from the low-
numbered block. Evaluation on the workspace ends when the evaluation pointer
reaches the last block in the list.
| Prev
| Start of Chapter | Next Chapter | Contents | Index | (12 out of 12)
Copyright © 1996, Gensym Corporation, Inc.