nanospin()

Ожидать без блокирования потока в течение заданного промежутка времени

Прототип:

#include <time.h>
int nanospin( const struct timespec *when );

Аргументы:

when
A pointer to a struct timespec that specifies the amount of time to busy-wait for. This is a duration, not an absolute time.

Библиотека:

libc

Описание:

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.) The function is essentially a do...while loop.


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.

Because of the nature of time measurement, the function might actually wait longer than the specified time.


The first time you call nanospin(), the C library invokes nanospin_calibrate() with an argument of 0 (interrupts enabled), if you haven't already called it.

Возвращаемое значение:

EOK
Успешное завершение.
E2BIG
The delay specified by when is greater than 500 milliseconds.

Note: A delay of more than a few milliseconds might not work on some processors. For longer delays, use the POSIX timer_*() functions.

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().

Классификация:

ЗОСРВ «Нейтрино»

Точка остановки потока
Нет
Обработчик прерываний
Смотри ниже
Обработчик сигналов
Да
В потоке
Да

Предостережения:

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.

Тематические ссылки:

nanosleep(), nanospin_calibrate(), nanospin_count(), nanospin_ns(), nanospin_ns_to_count(), sched_yield(), sleep(), timer_create(), struct timespec




Предыдущий раздел: Описание API системной библиотеки