Keil Logo


#include <rtx51tny.h>

char os_wait (
  unsigned char event_sel,      /* events to wait for */
  unsigned char ticks,          /* timer ticks to wait */
  unsigned int dummy);          /* unused argument */

The os_wait function halts the current task and waits for one or several events such as a time interval, a time-out, or a signal from another task or interrupt. The event_sel argument specifies the event or events to wait for and can be any combination of the following manifest constants:

Event Description
K_IVL Wait for the interval specified by ticks.
K_SIG Wait for a signal.
K_TMO Wait for a time-out specified by ticks.

Events can be logically ORed using the vertical bar character ('|'). For example, K_TMO | K_SIG, specifies that the task waits for a time-out or for a signal.

The ticks argument specifies the number of timer ticks to wait for an interval event (K_IVL) or a time-out event (K_TMO).

The dummy argument is provided for compatibility with RTX51 Full and is not used in RTX51 Tiny.


  • This function is part of the RTX51 Tiny Real-Time Operating System which is included only with the PK51 Professional Developer's Kit.
  • Refer to Events for more information about K_IVL, K_TMO, and K_SIG.
  • When K_SIG and K_IVL get combined, then the function os_reset_interval must be used to eliminate timer delay issues.
Return Value

When one of the specified events occurs, the task is put in the READY state. When the task resumes execution, os_wait returns the manifest constant that identifies the event which restarted the task. Possible return values are:

Return Value Description
RDY_EVENT The task's ready flag was set by either the os_set_ready or isr_set_ready routines.
SIG_EVENT A signal was received.
TMO_EVENT A time-out has completed or an interval has expired.
NOT_OK The value of the event_sel argument is invalid.
See Also

isr_send_signal, isr_set_ready, os_clear_signal, os_reset_interval, os_send_signal, os_set_ready, os_wait1, os_wait2

#include <rtx51tny.h>
#include <stdio.h>         /* for printf */

void tst_os_wait (void) _task_ 9  {
  while (1)  {
    char event;
    event = os_wait (K_SIG | K_TMO, 50, 0);

    switch (event)  {
    default:                     /* this never happens */

    case TMO_EVENT:              /* time-out; 50 tick time-out */

    case SIG_EVENT:              /* signal received */
      os_reset_interval (100);   /* must use os_reset_interval() to adjust possible delay issues */
  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.