RTduino Source Code Reference Manual
Functions
Time

Time-related functions and definitions. More...

Functions

void yield (void)
 Pauses the execution of the current task, allowing other tasks to run. More...
 
void delay (unsigned long ms)
 Delays the program for the specified number of milliseconds. More...
 
void delayMicroseconds (unsigned int us)
 Delays the program for the specified number of microseconds. More...
 
unsigned long millis (void)
 Returns the number of milliseconds since the Arduino board began running the current program. More...
 
unsigned long micros (void)
 Returns the number of microseconds since the Arduino board began running the current program. More...
 

Detailed Description

Time-related functions and definitions.

Function Documentation

◆ delay()

void delay ( unsigned long  ms)

Delays the program for the specified number of milliseconds.

Parameters
msThe number of milliseconds to delay.
See also
https://www.arduino.cc/reference/en/language/functions/time/delay

◆ delayMicroseconds()

void delayMicroseconds ( unsigned int  us)

Delays the program for the specified number of microseconds.

Parameters
usThe number of microseconds to delay.
See also
https://www.arduino.cc/reference/en/language/functions/time/delaymicroseconds

◆ micros()

unsigned long micros ( void  )

Returns the number of microseconds since the Arduino board began running the current program.

Returns
The number of microseconds since program start.
See also
https://www.arduino.cc/reference/en/language/functions/time/micros

◆ millis()

unsigned long millis ( void  )

Returns the number of milliseconds since the Arduino board began running the current program.

Returns
The number of milliseconds since program start.
See also
https://www.arduino.cc/reference/en/language/functions/time/millis

◆ yield()

void yield ( void  )

Pauses the execution of the current task, allowing other tasks to run.

The yield function is used to pause the execution of the current task, giving the RT-Thread scheduler an opportunity to run other tasks. This function is typically used in scenarios where a task voluntarily relinquishes control to the scheduler, allowing a cooperative multitasking system.

When a task calls yield, it enters a waiting state, and the scheduler may choose to run another task that is ready to execute. After yielding, the task that called yield may be scheduled to run again in the future.

Note
  • This function is essential for cooperative multitasking, where tasks voluntarily relinquish control to the scheduler.
  • In preemptive multitasking systems, tasks yield control based on the scheduler's predefined time slices.
  • The behavior of yield can vary depending on the underlying RT-Thread configuration and scheduler settings.
See also
https://www.arduino.cc/reference/en/language/functions/scheduler/yield