During a gate invocation, the process running-bit may become false in one domain and will become true in a second domain. The second domain will start running immediately after the first has stopped.
CALL (SVC 253) - The invoking domain enters the waiting state (i.e., its process-running bit becomes FALSE). The last key parameter passed is always a newly created (by the kernel) return key to the invoking domain. In anticipation of that return key being invoked (by some other program), the domain normally loads an entry block before executing a CALL.
RETURN (SVC 254) - The invoking domain's process-running bit becomes FALSE and the domain enters the available state. In anticipation of some start key to this domain being invoked (by some other program), the domain normally loads an entry block before executing a RETURN.
FORK (SVC 255) - The invoking domain remains running. Since it remains running, no entry block is loaded.
In an implicit invocation, the CALL invocation is simulated by the kernel, loading an entry block which specifies no keys, a zero parameter word, and a zero length parameter string. The invoking domain enters the waiting state and a resume key is created by the kernel and passed as the fourth key parameter.
The invoked key must be a gate key or the Error Key. If it is not, the implicit invocation does not take place and the invoking domain is left in the waiting state.
Figure 2-4
The invoking domain specifies the parameter word by loading it in general register 1.
If AA is 00, a zero length byte string data parameter is provided.
If AA is 01, general registers 2 and 3 specify the address and length respectively of the byte string data parameter. The length, in register 3, is considered as a 32-bit unsigned integer. The length must be less than or equal to 4096. If it is not, the trap code is set with TC0 = 5 and subcode 6.
If AA is 10, the trap code is set with TC0 = 5 and subcode 2.
If AA is 11, general registers 2 and 3 specify the address and length of the argument string within the registers. For this purpose the 32 bytes of floating registers 0 through 6 are considered to follow and be contiguously adjacent to the 64 bytes of the general registers.
Figure 2-5
For i from 1 through 4:
If the key being invoked is a resume key, all copies of it become DK(0).
The state of the invoking domain is adjusted according to the type of invocation (CALL, RETURN, or FORK) and its instruction address is advanced to the next sequential instruction.
In some implementations, a FORK invocation of a gate key may stall when establishing the new domain as "process-running" would exceed a process-running limit built into the kernel. In this case, the kernel may call the decongester to help. The domain issuing the FORK need not be aware of this.
If a start key is specified and the designated domain is busy, the invoking domain stalls. If the invoking domain is still at this point when the busy domain becomes available, the invocation will then proceed.
Some implementations may not recognize that the situation leading to the stall has changed in some way other than the invoked domain becoming available. In these implementations, the invoking domain will not proceed until the invoked domain becomes available or some other implementation-defined event occurs. Thus, if the invocation instruction that had caused the explicit invocation were changed to a NOP, the invoking domain would remain stalled despite its process-running bit being TRUE and the lack of an obstacle.
Normally, stalled invoking domains are restarted in the order that they became stalled. This is not always possible.
All the action of invoking a key depends on (uses the resources of) the meter of the invoking domain.
Design note: It might seem reasonable for a version of KeyKOS to provide buffering to avoid stalling. In this case, the invoked key and parameters would be held in a message and the disposition of the invoking domain would occur immediately. For example, a domain executing a FORK of a start key to a busy domain could find that the FORK completes (i.e., the domain goes on to the instruction after the FORK) while the action of invoking the start key has not yet occurred. This has not been implemented because of the difficulty of accounting for and limiting the storage required for the messages.
There are three kinds of resume keys:
If the invoked key is a start or return key, the entry block for the invocation is taken from floating register 2 of the invoked domain.
If the invoked key is a restart or fault key, the entry block will be X'10000000' (no parameters are accepted).
The format of the entry block is:
Figure 2-6
If C = 1 then the parameter word will be placed in general register 1 of the invoked domain. Otherwise, register 1 is unchanged.
If S = 1 then general register 4 holds the address (in either the invoked domain's virtual memory or its registers) of the parameter string, and register 5 holds the maximum length of the parameter string.
If L = 1 then the length of the argument string will be placed in general register 3.
If the argument string is shorter than the maximum length specified for the parameter string, values beyond the length of the argument string will remain unchanged. If it is longer, the remainder of the argument is not transmitted.
If R = 0 then the parameter string is in the invoked domain's virtual memory.
If R = 1 then the parameter string is in the invoked domain's registers. For this purpose the 32 bytes of floating registers 0 through 6 are considered to follow and be contiguously adjacent to the 64 bytes of the general registers (see Figure 2-5).
If some of the parameter string is in a page that is not defined read/write in the invoked domain's addressing segment, and some part of the argument string is to be placed in that page, then an addressing trap code will be produced in the invoked domain even when a write reference to that address by a problem mode instruction in the invoked domain would have caused a call invocation to a segment keeper. No segment keeper will be called. It is as if the reference to the parameter string had been made via a memory key with a no-call bit. In this case the portion of the argument that was to have been copied into that page is not copied but the rest of the invocation action proceeds.
If S = 0 then the argument string is not accepted and R and L are ignored.
If D = 1 then general register 2 of the invoked domain is set to a value determined by the gate key. If the gate key is a start key, the value is the data byte of the start key with 24 high order zeros. If the gate key is a resume key, the value is zero.
For i from 1 through 4:
If a return key to a running domain is invoked, the arguments may be deposited in the invoked domain (according to the invoked domain's current entry block in floating register 2) and the process-running bit will remain TRUE. If any resume key is used to a running domain, that domain may lose its place on some queue.
Programming note: Domains will never overlap with the current design of space banks and domain creators, if current domain creators are the only holders of the domain tool.
Each of these domains can be described as different objects of the same type.
Design Note: The trapping caused by rejected parameter words is inhibited for restart keys to prevent holders of restart keys from influencing (beyond impeding) the domain designated by the restart key.