C Microkernel Realtime eXecutive
Realtime Operating System for Cortex-M based microcontrollers
 
Loading...
Searching...
No Matches

Description

Kernel offers mechanism to interrupt, or periodically schedule execution of thread.

Kernel API provides two kinds of interruptions: one-time and periodic. one-time interruption is always synchronous - the thread won't be given control until delay elapses. Kernel is free to schedule any other thread in this time if delay is long enough.

Periodic delays are always asynchronous - the thread won't be stopped after the delay is scheduled. Once the delay elapses, kernel will deliver a signal to the requesting thread. If thread has nothing to do until the delay elapses, it may stop itself via calling kill() using SIG_STOP signal.

__SYSCALL int usleep (unsigned microseconds)
 Suspend thread execution for short time.
 
__SYSCALL int setitimer (unsigned microseconds)
 Set interval timer to be called periodically.
 

Function Documentation

◆ setitimer()

__SYSCALL int setitimer ( unsigned  microseconds)

Set interval timer to be called periodically.

Configures interval timer, which will periodically be called, until cancelled. Timer is called by delivering the SIGTIMER signal to the thread. If thread is stopped, then SIGTIMER will resume it and call signal handler. If there is no signal handler configured, then thread will just be resumed.

Parameters
microsecondsperiod of timer signals received. If set to 0, then interval timer is cancelled.

◆ usleep()

__SYSCALL int usleep ( unsigned  microseconds)

Suspend thread execution for short time.

Suspends thread execution for given amount of time. After this amount of time elapses, thread execution is resumed. Suspend is one-time and usleep() has to be called again in order to sleep again.

Parameters
microsecondsamount of microseconds (1/100000 s) to sleep
Note
Actual amount of time which thread will be suspended depends on system tick granularity and status of scheduler at the time of wake-up. If there is another thread running/ready with equal/higher priority, then actual wake-up may be delayed by the time consumed by this high-priority thread.