Chapter 3 Introduction to MR308
- 47 -
3.5.10 Time Management Function
The time management function provides system time management, time reading36, time setup37, and the func-
tions of the alarm handler, which actuates at preselected times, and the cyclic handler, which actuates at prese-
lected time intervals.
The MR308 kernel requires one timer for use as the system clock. There are following time management ser-
vice calls that are provided by the MR308 kernel. Note, however, that the system clock is not an essential func-
tion of MR308. Therefore, if the service calls described below and the time management function of the MR308
are unused, a timer does not need to be occupied for use by MR308.
• Place a task in a finite time wait state by specifying a timeout value A timeout can be specified in a service call that places the issuing task into WAITING state.38 This
service call includes tslp_tsk, twai_flg, twai_sem, tsnd_dtq, trcv_dtq, trcv_mbx, tget_mpf, vtsnd_dtq,
and vtrcv_dtq. If the wait cancel condition is not met before the specified timeout time elapses, the er-
ror code E_TMOUT is returned, and the task is freed from the wait state. If the wait cancel condition is
met, the error code E_OK is returned.
The timeout time should be specified in ms units.
50
tslp_tsk(50)
READY state
tslp_tsk(50)
iwup_tsk
E_OK
E_TMOUT
WAITING state
WAITING state
RUN state
Timeout value
Figure 3.38 Timeout Processing
MR308 guarantees that as stipulated in µITRON specification, timeout processing is not performed
until a time equal to or greater than the specified timeout value elapses. More specifically, timeout
processing is performed with the following timing.
1. If the timeout value is 0 (for only dly_tsk)
The task times out at the first time tick after the service call is issued.
2. If the timeout value is a multiple of time tick interval
The timer times out at the (timeout value / time tick interval) + first time tick. For example, if the
time tick interval is 10 ms and the specified timeout value is 40 ms, then the timer times out at
the fifth occurrence of the time tick. Similarly, if the time tick interval is 5 ms and the specified
timeout value is 15 ms, then the timer times out at the fourth occurrence of the time tick.
3. If the timeout value is not a multiple of time tick interval
The timer times out at the (timeout value / time tick interval) + second time tick. For example, if
the time tick interval is 10 ms and the specified timeout value is 35 ms, then the timer times out
36 get_tim service call
37 set_tim service call
38 SUSPENDED state is not included.