OSDisableInterrupts

Syntax

#include <cafe/os/OSInterrupts.h>

BOOL OSDisableInterrupts(void);

Parameters

None.

Return Values

Returns TRUE if interrupts were previously enabled, or FALSE if interrupts were previously disabled.

Description

Disables interrupt delivery for the current processor core in the current process. Other cores are unaffected. This can be helpful to create critical sections, etc., to prevent priority-inversion issues. OSDisableInterrupts takes few processor cycles (2+call). The result returns whether interrupts are currently enabled. The result is typically passed as the input parameter to OSRestoreInterrupts.

A common usage pattern is described below.

  1. Call OSDisableInterrupts.
  2. Acquire a raw spinlock.
  3. Perform the operation under the lock using a small number of cycles.
  4. Call OSRestoreInterrupts.

WARNING:
Interrupts should only be disabled for extremely brief periods of time, usually for low 100's of cycles or less if possible. Leaving interrupts disabled for any lengthy period of time (e.g., several 16ms video frames) will result in the OS and drivers performing poorly. For example, audio can skip or break up and graphics can stutter or worse.

Leaving interrupts disabled for an extended period of time (several seconds) can lead to your process being terminated by the system heartbeat watchdog.

Do Not Call From

None.

See Also

OSEnableInterrupts
OSRestoreInterrupts
OSIsInterruptEnabled
OSUninterruptibleSpinLock_Acquire
OSUninterruptibleSpinLock_Release
OSUninterruptibleSpinLock_TryAcquire
OSUninterruptibleSpinLock_TryAcquireWithTimeout

Revision History

2013/05/08 Automated cleanup pass.
2012/07/31 Cleanup Pass.
2012/04/12 Initial version.


CONFIDENTIAL