PREVIOUS
Meters, Resources, and Charge Sets
Meters measure and control the quantity of
resources that domains use. Meters may be used to
prevent domains from proceeding. Cutting off a meter does not
destroy data. The meter may be turned back on in such a way that
affected domains restart from where they left off. Meters are
organized into trees with the primordial meter at the root, domains
at the leaves, and meters at the nodes of the tree.
A meter key is a specific type of key that designates a
node. A meter is a node viewed through a meter key.
A node key may be used to obtain a meter key, which
permits the node to be used as a meter. A meter key only allows the
holder to use the node as a meter, or to create subsidiary meters.
Slot 1 of a meter node designates another meter node by a meter
key. The first meter is said to depend on the
second meter. If meter A depends on meter B, A is said to be inferior
to B and to all meters to which B is inferior. Any resource measured
by a meter is measured by the meter that it depends on (and by all
meters to which it is inferior).
A domain which depends on a meter node causes the counters in that
node to count the use of resources by the domain.
The primordial meter key is a valid level 0 meter key. B is a valid
meter of level n+1 if:
- The node it designates is correctly formatted, and
- Slot 1 holds a valid meter key of level n, and
- N is less than 20.
In other words, a valid meter key must (among other things) point to
the head of a chain of nodes, via slot 1 of those nodes, that leads to
the primordial meter key. This chain may involve only meter keys
and may have at most 20 keys.
The counters in a meter node (each of which is a data key) are decremented as the resources are used.
- The data key in slot 3 counts CPU time - This is the time the CPU devotes to
executing the program's instructions, including some of the time required for
system calls on behalf of the program. CPU time is measured in units of one
sixteenth of one microsecond. (.000001/16 second)
- The data key in slot 4 is reserved for measuring a future resource.
- The data key in slot 5 is reserved for measuring a future resource.
Programming note: When constructing meters, the data
keys in slots 4 and 5 should be initialized with data keys that are all
ones. This action will provide for compatibility with future versions
of KeyKOS by preventing meter traps for these resources.
When the CPU time counter in a meter
node is zero and a domain tries to decrement it, the counter
remains zero and the key in slot 2 of that meter node is implicitly
invoked. The key must be a gate key or the Error Key as described in the section in this chapter entitled,
"How a Domain Invokes a Key".
- The parameter word is -1.
- Key arguments 0 and 1 are DK(0).
- Key argument 2 is a node key to the meter with data byte 0.
- Key argument 3 is a restart key to the domain that
tried to decrement the meter.

Figure 2-7
Programming note: There is a programming convention for slot 14. When the CPU counter is zeroed to stop domains that
depend on the meter, the old value of the
counter is saved in Slot 14. This convention allows a single meter to
be used for both measuring elapsed CPU time and for stopping the
domains that depend on the meter.
Programming note: Whenever a domain's meter is invalid
(malformed) the kernel causes the
domain to trap to its domain keeper.
A charge set is used to determine how many
pages are referenced by domains running under one or more meters. Charge sets may be either
active or inactive. Inactive charge sets have no pages in them. Active
charge sets have zero or more pages and a 64-bit TOD value that is
set whenever the charge set is activated.
When a domain, running under a meter that holds a a charge set key,
references a page that is not already in the set, that page is added to
the set. If the set was inactive it is activated and its TOD value is set
to the current TOD value.
Implementations may arbitrarily inactivate a charge
set when its space is needed or for other reasons.
NEXT