Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/n/nanospin_ns_to_count.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/n/nanospin_ns_to_count.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/n/nanospin_ns_to_count.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/n/nanospin_ns_to_count.html on line 8

nanospin_ns_to_count()

Convert a time in nanoseconds into a number of iterations

Synopsis:

#include <time.h>

unsigned long nanospin_ns_to_count( 
                 unsigned long nsec );

Arguments:

nsec
The number of nanoseconds that you want to convert.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The nanospin_ns_to_count() function converts the number of nanoseconds specified in nsec into an iteration count suitable for nanospin_count().


Note: The nanospin*() functions are designed for use with hardware that requires short time delays between accesses. You should use them to delay only for times less than a few milliseconds. For longer delays, use the POSIX timer_*() functions.

The first time that you call nanospin_ns_to_count(), the C library invokes nanospin_calibrate() with an argument of 0 (interrupts enabled), if you haven't invoked it directly first.

Returns:

The amount of time to busy-wait, or -1 if an error occurred (errno is set).

Errors:

EINTR
A too-high rate of interrupts occurred during the calibration routine.
ENOSYS
This system's startup-* program didn't initialize the timing information necessary to use nanospin_ns_to_count().

Examples:

Busy-wait for at least one nanosecond:

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

unsigned long time = 1;

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

/*
 The C library invokes nanospin_calibrate
 if it hasn't already been called.
*/

nanospin_count( nanospin_ns_to_count( time ) );

/* Use the hardware. */
…

Classification:

QNX Neutrino

Safety:
Cancellation point No
Interrupt handler Read the Caveats
Signal handler Yes
Thread Yes

Caveats:

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.

See also:

nanospin(), nanospin_calibrate(), nanospin_count(), nanospin_ns(), timer_create()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/n/nanospin_ns_to_count.html on line 190

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/n/nanospin_ns_to_count.html on line 190