Cyclic Handler
A cyclic handler is a time event handler started at regular intervals. Cyclic handler functions are provided for creating and deleting a cyclic handler, activating and deactivating a cyclic handler operation, and referencing cyclic handler status. A cyclic handler is an object identified by an ID number called a cyclic handler ID.
The time interval at which a cyclic handler is started (cycle time) and the cycle phase are specified for each cyclic handler when it is created. When a cyclic handler operation is requested, µT-Kernel determines the time at which the cyclic handler should be started next based on the cycle time and cycle phase set for it. When a cyclic handler is created, the time when it is to be started next is the time of its creation plus the cycle phase. When the time comes to start a cyclic handler, exinf, containing extended information about the cyclic handler, is passed to it as a starting parameter. The time when the cyclic handler is started plus its cycle time becomes the next start time. Sometimes when a cyclic handler is activated, the next start time will be newly set.
The cycle phase of the cyclic handler is less than or equal to cycle time in principle, but if the time set for the cycle phase is longer than the cycle time, the cyclic handler is invoked first after the time specified for the cycle phase has passed. For example, if the cycle time is 100 ms and the cycle phase is 200 ms, the cyclic handler is first invoked after 200ms has elapsed, and then invoked after 200+100*(n-1) ms of time has elapsed.
A cyclic handler has two activation states, active and inactive. While a cyclic handler is inactive, it is not started even when its start time arrives, although calculation of the next start time does take place. When a system call for activating a cyclic handler is called (tk_sta_cyc), the cyclic handler goes to active state, and the next start time is decided if necessary. When a system call for deactivating a cyclic handler is called (tk_stp_cyc), the cyclic handler goes to inactive state. Whether a cyclic handler is active or inactive upon creation is decided by a cyclic handler attribute.
The cycle phase of a cyclic handler is a relative time specifying the first time the cyclic handler is to be started in relation to the time when the system call creating it was invoked. The cycle time of a cyclic handler is likewise a relative time, specifying the next time the cyclic handler is to be started in relation to the time it should have started (not the time it started). For this reason, the intervals between times when the cyclic handler is started will individually be shorter than the cycle time in some cases, but their average over a longer time span will match the cycle time.

Comments
Click here to Post a Comment