Keil Logo


Events in a real-time operating system may be used to control the execution of tasks in the program. A task may wait for an event or may set event flags for other tasks.

The os_wait function allows a task to wait for one or more events.

  • Timeout is a common event for which a task can wait. A timeout is simply a number of clock ticks. While a task waits for a timeout, other tasks may execute. Once the specified number of timer ticks elapses, the task may continue execution.
  • Interval is a variation of the Timeout. An interval is like a timeout except that the specified number of clock ticks is relative to the last time the os_wait function was invoked by the task. The Interval may be used to generate a task which is run on a regular, synchronous schedule (like once every second) regardless of how long the task takes between calls to the os_wait function. If the specified number of clock ticks have already elapsed (since the os_wait function was last invoked) the task is re-started immediately—no other tasks execute.
  • Signal is a simple form of inter-task communication. A task can wait for another task to send it a signal (with the os_send_signal and isr_send_signal functions).
  • Each task has a Ready flag which may be set by other tasks (with the os_set_ready and isr_set_ready functions). A task that is waiting for a timeout, interval, or signal may be started by setting its ready flag.

Each event has an associated event flag that RTX51 Tiny maintains. The following event selectors may be used with the os_wait function to specify what to wait for:

Event Selector Description
K_IVL Wait for the specified interval.
K_SIG Wait for a signal.
K_TMO Wait for a specified timeout.

When the os_wait functio returns, the events that occurred are specified by the return value:

Return Value Description
RDY_EVENT The task's ready flag was set.
SIG_EVENT A signal was received.
TMO_EVENT A time-out has completed or an interval has elapsed.

The os_wait function may wait for the following combinations of events:

  • K_SIG | K_TMO: os_wait delays the task until a signal is sent to it or until the specified number of clock ticks has elapsed.
  • K_SIG | K_IVL: os_wait delays the task until a signal is sent to it or until the specified interval has elapsed. In this case, you must use the function os_reset_interval to eliminate timer delay issues.


  • The K_IVL and K_TMO event selectors may not be combined.
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.