[Previous] [Contents] [Next]

nanospin()

Busy-wait without blocking for a period of time

Synopsis:

#include <time.h>

int nanospin( const struct timespec *when );

Library:

libc

Description:

The nanospin() function busy-waits for the amount of time specified in when without blocking the calling thread. The when argument is a duration, not an absolute time.

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.

The first time nanospin() is called, the C library invokes nanospin_calibrate(), if the user hasn't already called it.

Returns:

0
Success.
-1
An error occurred; errno is set.

Errors:

E2BIG
The delay specified by when is greater than 500 milliseconds.
ENOSYS
This system's startup-* program didn't initialize the timing information necessary to use nanospin().

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_calibrate(), nanospin_count(), nanospin_ns(), nanospin_ns_to_count(), sched_yield(), sleep()


[Previous] [Contents] [Next]