Intuitively, there seems to be two circumstances in which a domain gains control:
Similarly, there are two reasons for control to leave a domain:
The three domain states, running, waiting and available, exist to support this distinction. While a domain has its process running bit TRUE, it is running. After domain A calls domain B, but before domain B returns, domain A is waiting A domain that is either running or waiting is busy. This ensures that no new domain will become active until the current case is finished and the working storage is no longer required. After a domain is finished with the current case it returns and is then available (for another case).
Useful connotations for the domain states can be provided by means of the following analogy:
Imagine a house (domain) with front and back doors. Assume there is no one in the house and both doors are locked. (The domain is available.) A workman (process) enters (calls) the house (domain) through the front door with a front door key (start key). The workman brought some information (data parameters) and keys to other houses (key parameters) when he entered the house. As the workman enters the house (process enters the domain) the front door is bolted from the inside (domain becomes running) - because there is not room for more than one workman in the house. (Only one process in a domain.)
While in the house, the workman faithfully obeys instructions that are part of the house. If certain tools are lacking in this house the workman may have to visit another house (call another domain). He must have a key to the new house which he might have brought with him originally or, more likely, have found in the current house. He leaves the current house via the back door, leaving the front door bolted and the back door locked (the domain is in the waiting state). The front door must remain bolted because the workman's job setup must not be disturbed. In the process of leaving, a key magically appears that will enable him to return through the back door. (A return key will be produced that permits any holder of that key to reenter the domain.)
The workman (or another with the same return key) subsequently returns through the back door (reenters the domain with the return key, and the domain becomes running again.) During this time the front door remains bolted (domain busy); any other workman trying to enter will wait at the front door until it is unbolted. As the first workman leaves he may take with him information or keys that he had access to while in the house, but note that he is faithfully obeying the instructions of the house. As he leaves he unbolts the front door. (The domain becomes available.) He does not notice the other workman who quickly enters the house and bolts the door.
Sometimes something happens to the domain that is not supposed to concern the logic of the program in the domain. An example of this is a page fault in a segment that another domain is responsible for mending. Another example is a decision by some scheduling authority that the program should be suspended for a while in order to share . Another type of blockage is due to a program interrupt that is due to the logic of the program, but is typically unanticipated by the program. An exponent overflow is an example of this. In all these cases the domain executes an implicit invocation and enters the waiting state.