3.2.7 Timeout

A system call that may enter WAIT state has a timeout function. If processing is not completed by the time the specified timeout interval has elapsed, the processing is canceled and the system call returns error code E_TMOUT.

In accord with the principle that there should be no side-e.ects from calling a system call if that system call returns an error code, the calling of a system call that times out should in principle result in no change in system state. An exception to this is when the functioning of the system call is such that it cannot return to its original state if processing is canceled. This is indicated in the system call description.

If the timeout interval is set to 0, a system call does not enter even when a situation arises in which it would ordinarily go to WAIT state. In other words, a system call with timeout set to 0 when it is invoked has no possibility of entering WAIT state. Invoking a system call with timeout set to 0 is called polling; that is, a system call that performs polling has no chance of entering WAIT state.

The descriptions of individual system calls as a rule describe the behavior when there is no timeout (in other words, when an endless wait occurs). Even if the system call description says that the system call “enters WAIT state” or “is put in WAIT state”, if a timeout is set and that time interval elapses before processing is completed, the WAIT state is released and the system call returns error code E_TMOUT. In the case of polling, the system call returns E_TMOUT without entering WAIT state. Timeout (TMO type) is made as a positive integer, or as TMO_POL (= 0) for polling, or as TMO_FEVR (= .1) for endless wait. If a timeout interval is set, the timeout processing must be guaranteed to take place even after the specified interval from the system call issuing has elapsed.

[Additional Notes]

Since a system call that performs polling does not enter WAIT state, there is no change in the precedence of the task calling it. In a general implementation, when the timeout is set to 1, timeout processing takes place on the second time tick after a system call is invoked. Since a timeout of 0 cannot be specified (0 being allocated to TMO_POL), in this kind of implementation timeout does not occur on the initial time tick after the system call is invoked.

Comments