Busy-wait without blocking for a period of time
#include <time.h> int nanospin_ns( unsigned long nsec );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The nanospin_ns() function busy-waits for the number of nanoseconds specified in nsec, without blocking the calling thread.
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.
The first time you call nanospin_ns(), the C library invokes nanospin_calibrate() with an argument of 0 (interrupts enabled), if you haven't invoked it directly first.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | Read the Caveats |
Signal handler | Yes |
Thread | Yes |
You should use busy-waiting only when absolutely necessary for accessing hardware.
It isn't safe to call this function in an interrupt handler if nanospin_calibrate() hasn't been called yet.