Updated: April 19, 2023 |
Busy-wait without thread blocking for a period of time
#include <time.h> int nanospin( const struct timespec *when );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The nanospin() function occupies the CPU for the amount of time specified by the argument when without blocking the calling thread. (The thread isn't taken off the ready list.) This function is essentially a busy-wait loop based on the value returned by ClockCycles().
Because of the nature of time measurement, the function might actually wait longer than the specified time. For more information, see the Understanding the Microkernel's Concept of Time chapter of the QNX Neutrino Programmer's Guide.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |
You should use busy-waiting only when absolutely necessary for accessing hardware.