Keil Logo Arm Logo

RTX166 Tiny User's Guide

Events

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.

  • The 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.
  • The 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 os_wait. 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.
  • A 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 event has an associated event flag that RTX166 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 function 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.

Note

  • The K_IVL and K_TMO event selectors may not be combined.

Keil logo

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.