Keil™, An ARM® Company

RTX166 Tiny User's Guide

os_wait

Summary
#include <rtx166t.h>

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

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:

EventDescription
K_IVLWait for the interval specified by ticks.
K_SIGWait for a signal.
K_TMOWait for a time-out specified by ticks.

Events may be logically ORed using the vertical bar character ('|'). For example, K_TMO | K_SIG, specifies that the task wait 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 RTX166 Full and is not used in RTX166 Tiny.

Note

  • This function is part of the RTX166 Tiny Real-Time Operating System.
  • Refer to Events for more information about K_IVL, K_TMO, and K_SIG.
Return Value

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

Return ValueDescription
RDY_EVENTThe task's ready flag was set by either the os_set_ready or isr_set_ready routines.
SIG_EVENTA signal was received.
TMO_EVENTA time-out has completed or an interval has expired.
NOT_OKThe value of the event_sel argument is invalid.
See Also

isr_send_signal, os_clear_signal, os_delay_task, os_send_signal, os_wait_signal

Example
#include <rtx166t.h>
#include <stdio.h>       /* for printf */

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

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

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

    case SIG_EVENT:      /* signal received */
      break;
    }
  }
}

Related Knowledgebase Articles