# OS_SpinWait*

## Syntax

  `#include <nitro/os.h>`
  `void OS_SpinWait( u32 cycles );
  void OS_SpinWaitCpuCycles( u32 cycles );
  void OS_SpinWaitSysCycles( u32 cycles );`

## Arguments

`cycles`

Number of cycles to wait.
With the `OS_SpinWait` function, this is based on a 2x multiplier of the base cycle.
With the `OS_SpinWaitCpuCycles` function, this is based on CPU cycles.
With the `OS_SpinWaitSysCycles` function, this is based on the base cycles.

## Return Values

None.

## Description

Makes the CPU run empty loops for at least the number of cycles specified by `cycles`.

This function only causes empty loop processing. Therefore, be aware that the return time from this function may be greatly delayed by interrupts that are generated during the loops.

Because of function calls and other overhead, return from this function might be delayed slightly more than the specified number of cycles.

The `OS_SpinWaitCpuCycles` function is based on the CPU cycles.

The `OS_SpinWaitSysCycles` function is based on base cycles. This is independent of mode (NITRO or TWL) or changes to the CPU frequency.

The `OS_SpinWait` function is based on a fixed value that is unrelated to the operating frequency of the CPU. It was created for the sake of compatibility with NITRO. For the ARM9, it is based on a 2x multiplier of the base cycle. For the ARM7, it is based on the base cycles. On NITRO, the `OS_SpinWait` function was used as empty looping based on CPU cycles. Because the CPU frequency can be changed on TWL, however, it is set up this way for convenience when NITRO source code is used.

The frequencies used as the basis for the the number of cycles (`cycles`) are shown below.

> `OS_SpinWait`

> Platform | Frequency Used as the Basis for `cycles`
> --- | ---
> ARM9 | ARM7
> NITRO | 67.03 MHz | 33.51 MHz
> TWL

> `OS_SpinWaitCpuCycles`

> Platform | Frequency Used as the Basis for `cycles`
> --- | ---
> ARM9 | ARM7
> NITRO | 67.03 MHz | 33.51 MHz
> TWL | 67.03 MHz (When running at standard speed) 134.06 MHz (When running at 2x speed)

> `OS_SpinWaitSysCycles`

> Platform | Frequency Used as the Basis for `cycles`
> --- | ---
> ARM9 | ARM7
> NITRO | 33.51 MHz
> TWL

## See Also

`SVC_WaitByLoop`

## Revision History

2007/09/27 Added descriptions of the `OS_SpinWaitCpuCycles` and `OS_SpinWaitSysCycles` functions.
2004/02/27 Initial version.

CONFIDENTIAL