Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Periodic Tick

Nearly every RTOS requires a periodic time source called a Clock Tick or System Tick to keep track of time delays and timeouts. µC/OS-III’s clock tick handling is encapsulated in the file os_tick.c.

OS_TickTask() is a task created by µC/OS-III and its priority is configurable by the user through µC/OS-III’s configuration file os_cfg_app.h (see OS_CFG_TICK_TASK_PRIO). Typically OS_TickTask() is set to a relatively high priority but should be slightly lower in priority than your most important tasks.

OS_TickTask() is used by µC/OS-III to keep track of tasks waiting for time to expire or, for tasks that are pending on kernel objects with a timeout. OS_TickTask() is a periodic task and it waits for signals from the tick ISR (described in Interrupt Management) as shown in the figure below.

µC/OS-III may need to place literally hundreds of tasks (if an application has that many tasks) in the tick list. The tick list is implemented such that it takes as little CPU time as possible to determine if time has expired for those tasks placed in the tick list and, possibly makes those tasks ready-to-run. In fact, the tick management has been completely redesigned as of V3.04.00 and the tick list is actually split into two separate ‘delta-lists’ as shown in the figure below.

Tasks are automatically inserted in the proper Since its initial release, µC/OS-III iterated through several methods of managing task delays and timeouts. V3.04.00 introduced the concept of a delta-list, which reduced the overhead involved in checking for timeouts and expired delays; however, that initial implementation maintained two separate lists for tracking timeouts and delays.

V3.07 merged the two lists into one, called OSTickList, in order to reduce memory consumption and overhead 

Tasks are automatically inserted into the tick list when the application programmer calls an OSTimeDly???() function, or when an OS???Pend() call is made with a non-zero timeout value. If the users application does not need time delays or timeouts, the user can remove the Tick Task from µC/OS-III, see the µC-OS-III Configuration Manual for more information. A task is usually removed from the tick list by the tick ISR once its delay or timeout has expired. It may also be removed if the time delay is resumed or the pend with timeout is aborted.

Example

Using an example to illustrate the process of inserting a task in the delayed tick list. Here, we assume that the OSTickListDly list is completely empty as shown in the figure belowabove. A task is placed in the tick list when OSTimeDly() is called and let’s assume OSTimeDly() is called as follows:

...