ReactOS 0.4.16-dev-106-g10b08aa
spinlock.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for spinlock.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

KIRQL KeAcquireSpinLockRaiseToSynch (PKSPIN_LOCK SpinLock)
 
KIRQL NTAPI KeAcquireSpinLockRaiseToDpc (PKSPIN_LOCK SpinLock)
 
VOID NTAPI KeReleaseSpinLock (PKSPIN_LOCK SpinLock, KIRQL OldIrql)
 
KIRQL KeAcquireQueuedSpinLock (IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
 
KIRQL KeAcquireQueuedSpinLockRaiseToSynch (IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
 
VOID KeAcquireInStackQueuedSpinLock (IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
 
VOID KeAcquireInStackQueuedSpinLockRaiseToSynch (IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
 
VOID KeReleaseQueuedSpinLock (IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
 
VOID KeReleaseInStackQueuedSpinLock (IN PKLOCK_QUEUE_HANDLE LockHandle)
 
BOOLEAN KeTryToAcquireQueuedSpinLockRaiseToSynch (IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN PKIRQL OldIrql)
 
LOGICAL KeTryToAcquireQueuedSpinLock (IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, OUT PKIRQL OldIrql)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file spinlock.c.

Function Documentation

◆ KeAcquireInStackQueuedSpinLock()

VOID KeAcquireInStackQueuedSpinLock ( IN PKSPIN_LOCK  SpinLock,
IN PKLOCK_QUEUE_HANDLE  LockHandle 
)

Definition at line 102 of file spinlock.c.

104{
105 /* Set up the lock */
108
109 /* Raise to dispatch */
111
112 /* Acquire the lock */
113 KxAcquireSpinLock(LockHandle->LockQueue.Lock); // HACK
114}
#define NULL
Definition: types.h:112
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
KSPIN_LOCK_QUEUE LockQueue
Definition: ketypes.h:627
struct _KSPIN_LOCK_QUEUE *volatile Next
Definition: ketypes.h:622
PKSPIN_LOCK volatile Lock
Definition: ketypes.h:623
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:228
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:717

◆ KeAcquireInStackQueuedSpinLockRaiseToSynch()

VOID KeAcquireInStackQueuedSpinLockRaiseToSynch ( IN PKSPIN_LOCK  SpinLock,
IN PKLOCK_QUEUE_HANDLE  LockHandle 
)

Definition at line 121 of file spinlock.c.

123{
124 /* Set up the lock */
127
128 /* Raise to synch */
130
131 /* Acquire the lock */
132 KxAcquireSpinLock(LockHandle->LockQueue.Lock); // HACK
133}
#define SYNCH_LEVEL
Definition: env_spec_w32.h:704

◆ KeAcquireQueuedSpinLock()

KIRQL KeAcquireQueuedSpinLock ( IN KSPIN_LOCK_QUEUE_NUMBER  LockNumber)

Definition at line 70 of file spinlock.c.

71{
73
74 /* Raise to dispatch */
76
77 /* Acquire the lock */
78 KxAcquireSpinLock(KeGetCurrentPrcb()->LockQueue[LockNumber].Lock); // HACK
79 return OldIrql;
80}
UCHAR KIRQL
Definition: env_spec_w32.h:591
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1161
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:127
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

◆ KeAcquireQueuedSpinLockRaiseToSynch()

KIRQL KeAcquireQueuedSpinLockRaiseToSynch ( IN KSPIN_LOCK_QUEUE_NUMBER  LockNumber)

Definition at line 86 of file spinlock.c.

87{
89
90 /* Raise to synch */
92
93 /* Acquire the lock */
94 KxAcquireSpinLock(KeGetCurrentPrcb()->LockQueue[LockNumber].Lock); // HACK
95 return OldIrql;
96}

◆ KeAcquireSpinLockRaiseToDpc()

KIRQL NTAPI KeAcquireSpinLockRaiseToDpc ( PKSPIN_LOCK  SpinLock)

Definition at line 41 of file spinlock.c.

42{
44
45 /* Raise to dispatch */
47
48 /* Acquire the lock and return */
49 KxAcquireSpinLock(SpinLock);
50 return OldIrql;
51}

◆ KeAcquireSpinLockRaiseToSynch()

KIRQL KeAcquireSpinLockRaiseToSynch ( PKSPIN_LOCK  SpinLock)

Definition at line 24 of file spinlock.c.

25{
27
28 /* Raise to sync */
30
31 /* Acquire the lock and return */
32 KxAcquireSpinLock(SpinLock);
33 return OldIrql;
34}

◆ KeReleaseInStackQueuedSpinLock()

VOID KeReleaseInStackQueuedSpinLock ( IN PKLOCK_QUEUE_HANDLE  LockHandle)

Definition at line 155 of file spinlock.c.

156{
157 /* Simply lower IRQL back */
158 KxReleaseSpinLock(LockHandle->LockQueue.Lock); // HACK
160}
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602

◆ KeReleaseQueuedSpinLock()

VOID KeReleaseQueuedSpinLock ( IN KSPIN_LOCK_QUEUE_NUMBER  LockNumber,
IN KIRQL  OldIrql 
)

Definition at line 140 of file spinlock.c.

142{
143 /* Release the lock */
144 KxReleaseSpinLock(KeGetCurrentPrcb()->LockQueue[LockNumber].Lock); // HACK
145
146 /* Lower IRQL back */
148}

◆ KeReleaseSpinLock()

VOID NTAPI KeReleaseSpinLock ( PKSPIN_LOCK  SpinLock,
KIRQL  OldIrql 
)

Definition at line 58 of file spinlock.c.

60{
61 /* Release the lock and lower IRQL back */
62 KxReleaseSpinLock(SpinLock);
64}

◆ KeTryToAcquireQueuedSpinLock()

LOGICAL KeTryToAcquireQueuedSpinLock ( IN KSPIN_LOCK_QUEUE_NUMBER  LockNumber,
OUT PKIRQL  OldIrql 
)

Definition at line 190 of file spinlock.c.

192{
193 /* Raise to dispatch level */
195
196#ifdef CONFIG_SMP
197 // HACK
198 return KeTryToAcquireSpinLockAtDpcLevel(KeGetCurrentPrcb()->LockQueue[LockNumber].Lock);
199#else
200
201 /* Add an explicit memory barrier to prevent the compiler from reordering
202 memory accesses across the borders of spinlocks */
204
205 /* Always return true on UP Machines */
206 return TRUE;
207#endif
208}
#define TRUE
Definition: types.h:120
BOOLEAN FASTCALL KeTryToAcquireSpinLockAtDpcLevel(IN OUT PKSPIN_LOCK SpinLock)
Definition: spinlock.c:309
#define KeMemoryBarrierWithoutFence()
Definition: ke.h:66

◆ KeTryToAcquireQueuedSpinLockRaiseToSynch()

BOOLEAN KeTryToAcquireQueuedSpinLockRaiseToSynch ( IN KSPIN_LOCK_QUEUE_NUMBER  LockNumber,
IN PKIRQL  OldIrql 
)

Definition at line 167 of file spinlock.c.

169{
170 /* Raise to synch level */
172
173#ifdef CONFIG_SMP
174 // HACK
175 return KeTryToAcquireSpinLockAtDpcLevel(KeGetCurrentPrcb()->LockQueue[LockNumber].Lock);
176#else
177 /* Add an explicit memory barrier to prevent the compiler from reordering
178 memory accesses across the borders of spinlocks */
180
181 /* Always return true on UP Machines */
182 return TRUE;
183#endif
184}