ReactOS  0.4.13-dev-455-g28ed234
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 */
114 }
PKSPIN_LOCK volatile Lock
Definition: ketypes.h:611
struct _KSPIN_LOCK_QUEUE *volatile Next
Definition: ketypes.h:610
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE VOID KxAcquireSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.h:20
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
KSPIN_LOCK_QUEUE LockQueue
Definition: ketypes.h:615
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:742

◆ 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 */
133 }
PKSPIN_LOCK volatile Lock
Definition: ketypes.h:611
struct _KSPIN_LOCK_QUEUE *volatile Next
Definition: ketypes.h:610
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE VOID KxAcquireSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.h:20
#define SYNCH_LEVEL
Definition: env_spec_w32.h:704
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
KSPIN_LOCK_QUEUE LockQueue
Definition: ketypes.h:615
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:742

◆ KeAcquireQueuedSpinLock()

KIRQL KeAcquireQueuedSpinLock ( IN KSPIN_LOCK_QUEUE_NUMBER  LockNumber)

Definition at line 70 of file spinlock.c.

71 {
72  KIRQL OldIrql;
73 
74  /* Raise to dispatch */
76 
77  /* Acquire the lock */
78  KxAcquireSpinLock(KeGetCurrentPrcb()->LockQueue[LockNumber].Lock); // HACK
79  return OldIrql;
80 }
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1062
UCHAR KIRQL
Definition: env_spec_w32.h:591
FORCEINLINE VOID KxAcquireSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.h:20
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment IN PNDIS_RW_LOCK Lock
Definition: CrNtStubs.h:75
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27

◆ KeAcquireQueuedSpinLockRaiseToSynch()

KIRQL KeAcquireQueuedSpinLockRaiseToSynch ( IN KSPIN_LOCK_QUEUE_NUMBER  LockNumber)

Definition at line 86 of file spinlock.c.

87 {
88  KIRQL OldIrql;
89 
90  /* Raise to synch */
92 
93  /* Acquire the lock */
94  KxAcquireSpinLock(KeGetCurrentPrcb()->LockQueue[LockNumber].Lock); // HACK
95  return OldIrql;
96 }
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1062
UCHAR KIRQL
Definition: env_spec_w32.h:591
FORCEINLINE VOID KxAcquireSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.h:20
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment IN PNDIS_RW_LOCK Lock
Definition: CrNtStubs.h:75
#define SYNCH_LEVEL
Definition: env_spec_w32.h:704
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27

◆ KeAcquireSpinLockRaiseToDpc()

KIRQL NTAPI KeAcquireSpinLockRaiseToDpc ( PKSPIN_LOCK  SpinLock)

Definition at line 41 of file spinlock.c.

42 {
43  KIRQL OldIrql;
44 
45  /* Raise to dispatch */
47 
48  /* Acquire the lock and return */
50  return OldIrql;
51 }
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
UCHAR KIRQL
Definition: env_spec_w32.h:591
FORCEINLINE VOID KxAcquireSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.h:20
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27

◆ KeAcquireSpinLockRaiseToSynch()

KIRQL KeAcquireSpinLockRaiseToSynch ( PKSPIN_LOCK  SpinLock)

Definition at line 24 of file spinlock.c.

25 {
26  KIRQL OldIrql;
27 
28  /* Raise to sync */
30 
31  /* Acquire the lock and return */
33  return OldIrql;
34 }
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
UCHAR KIRQL
Definition: env_spec_w32.h:591
FORCEINLINE VOID KxAcquireSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.h:20
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define SYNCH_LEVEL
Definition: env_spec_w32.h:704
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27

◆ KeReleaseInStackQueuedSpinLock()

VOID KeReleaseInStackQueuedSpinLock ( IN PKLOCK_QUEUE_HANDLE  LockHandle)

Definition at line 155 of file spinlock.c.

156 {
157  /* Simply lower IRQL back */
160 }
PKSPIN_LOCK volatile Lock
Definition: ketypes.h:611
FORCEINLINE VOID KxReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.h:35
KSPIN_LOCK_QUEUE LockQueue
Definition: ketypes.h:615
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:742
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39

◆ 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 }
FORCEINLINE VOID KxReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.h:35
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1062
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment IN PNDIS_RW_LOCK Lock
Definition: CrNtStubs.h:75
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39

◆ 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 */
64 }
FORCEINLINE VOID KxReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.h:35
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39

◆ KeTryToAcquireQueuedSpinLock()

LOGICAL KeTryToAcquireQueuedSpinLock ( IN KSPIN_LOCK_QUEUE_NUMBER  LockNumber,
OUT PKIRQL  OldIrql 
)

Definition at line 190 of file spinlock.c.

192 {
193 #ifndef CONFIG_SMP
194  /* Simply raise to dispatch */
196 
197  /* Add an explicit memory barrier to prevent the compiler from reordering
198  memory accesses across the borders of spinlocks */
200 
201  /* Always return true on UP Machines */
202  return TRUE;
203 #else
205  ASSERT(FALSE);
206 #endif
207 }
#define TRUE
Definition: types.h:120
#define KeMemoryBarrierWithoutFence()
Definition: ke.h:66
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
#define UNIMPLEMENTED
Definition: debug.h:114

◆ KeTryToAcquireQueuedSpinLockRaiseToSynch()

BOOLEAN KeTryToAcquireQueuedSpinLockRaiseToSynch ( IN KSPIN_LOCK_QUEUE_NUMBER  LockNumber,
IN PKIRQL  OldIrql 
)

Definition at line 167 of file spinlock.c.

169 {
170 #ifndef CONFIG_SMP
171  /* Simply raise to dispatch */
173 
174  /* Add an explicit memory barrier to prevent the compiler from reordering
175  memory accesses across the borders of spinlocks */
177 
178  /* Always return true on UP Machines */
179  return TRUE;
180 #else
182  ASSERT(FALSE);
183 #endif
184 }
#define TRUE
Definition: types.h:120
#define KeMemoryBarrierWithoutFence()
Definition: ke.h:66
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
#define UNIMPLEMENTED
Definition: debug.h:114