[Previous] [Contents] [Next]

nanospin_count()

Busy-wait without blocking for a number of iterations

Synopsis:

#include <time.h>

void nanospin_count( unsigned long count );

Library:

libc

Description:

The nanospin_count() function busy-waits for the number of iterations specified in count. Use the nanospin_ns_to_count() function to turn a number of nanoseconds into an iteration count suitable for nanospin_count().

The nanospin*() functions are designed for use with hardware that requires short time delays between accesses. They should be used only to delay for times less than a few milliseconds.

Examples:

To busy-wait for at least 100 nanoseconds:

#include <time.h>
#include <sys/syspage.h>

unsigned long time = 100;

...
/* Wake up the hardware, then wait for it to be ready. */

nanospin_count( nanospin_ns_to_count( time ) );

/* Use the hardware. */
...

Classification:

QNX 6

Safety:
Cancellation point No
Interrupt handler Yes
Signal handler Yes
Thread Yes

Caveats:

Busy-waiting should be used only when absolutely necessary for accessing hardware.

See also:

nanosleep(), nanospin(), nanospin_calibrate(), nanospin_ns(), nanospin_ns_to_count(), sched_yield(), sleep()


[Previous] [Contents] [Next]