3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/hal/x86/spinlock.c
6 * PURPOSE: Implements spinlocks
7 * PROGRAMMER: David Welch (welch@cwcom.net)
8 * Eric Kohl (ekohl@rz-online.de)
14 * NOTE: On a uniprocessor machine spinlocks are implemented by raising
18 /* INCLUDES ****************************************************************/
20 #include <ddk/ntddk.h>
22 #include <internal/debug.h>
24 /* FUNCTIONS ***************************************************************/
32 * FUNCTION: Acquires a spinlock
34 * SpinLock = Spinlock to acquire
35 * OldIrql (OUT) = Caller supplied storage for the previous irql
38 *OldIrql
= KfAcquireSpinLock(SpinLock
);
42 KeAcquireSpinLockRaiseToSynch (
48 OldIrql
= KfRaiseIrql(SYNCH_LEVEL
);
49 KiAcquireSpinLock(SpinLock
);
60 * FUNCTION: Releases a spinlock
62 * SpinLock = Spinlock to release
63 * NewIrql = Irql level before acquiring the spinlock
66 KfReleaseSpinLock(SpinLock
, NewIrql
);
76 ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL
);
78 OldIrql
= KfRaiseIrql(DISPATCH_LEVEL
);
79 KiAcquireSpinLock(SpinLock
);
90 * FUNCTION: Releases a spinlock
92 * SpinLock = Spinlock to release
93 * NewIrql = Irql level before acquiring the spinlock
96 ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL
|| KeGetCurrentIrql() == SYNCH_LEVEL
);
97 KiReleaseSpinLock(SpinLock
);