ReactOS 0.4.16-dev-91-g764881a
spinlock.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 _Acquires_nonreentrant_lock_ (SpinLock) FORCEINLINE VOID KxAcquireSpinLock(_Unreferenced_parameter_ PKSPIN_LOCK SpinLock)
 
 _Releases_nonreentrant_lock_ (SpinLock) FORCEINLINE VOID KxReleaseSpinLock(_Unreferenced_parameter_ PKSPIN_LOCK SpinLock)
 

Function Documentation

◆ _Acquires_nonreentrant_lock_()

_Acquires_nonreentrant_lock_ ( SpinLock  )

Definition at line 18 of file spinlock.h.

28{
29#if DBG
30 /* Make sure that we don't own the lock already */
31 if (((KSPIN_LOCK)KeGetCurrentThread() | 1) == *SpinLock)
32 {
33 /* We do, bugcheck! */
34 KeBugCheckEx(SPIN_LOCK_ALREADY_OWNED, (ULONG_PTR)SpinLock, 0, 0, 0);
35 }
36#endif
37
38#ifdef CONFIG_SMP
39 /* Try to acquire the lock */
41 {
42#if defined(_M_IX86) && DBG
43 /* On x86 debug builds, we use a much slower but useful routine */
44 Kii386SpinOnSpinLock(SpinLock, 5);
45#else
46 /* It's locked... spin until it's unlocked */
47 while (*(volatile KSPIN_LOCK *)SpinLock & 1)
48 {
49 /* Yield and keep looping */
51 }
52#endif
53 }
54#endif
55
56 /* Add an explicit memory barrier to prevent the compiler from reordering
57 memory accesses across the borders of spinlocks */
59
60#if DBG
61 /* On debug builds, we OR in the KTHREAD */
63#endif
64}
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define KeGetCurrentThread
Definition: hal.h:55
#define InterlockedBitTestAndSet
Definition: interlocked.h:30
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
#define KeMemoryBarrierWithoutFence()
Definition: ke.h:66
#define YieldProcessor
Definition: ke.h:48
uint32_t ULONG_PTR
Definition: typedefs.h:65
int32_t * PLONG
Definition: typedefs.h:58
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:228

◆ _Releases_nonreentrant_lock_()

_Releases_nonreentrant_lock_ ( SpinLock  )

Definition at line 69 of file spinlock.h.

79{
80#if DBG
81 /* Make sure that the threads match */
82 if (((KSPIN_LOCK)KeGetCurrentThread() | 1) != *SpinLock)
83 {
84 /* They don't, bugcheck */
85 KeBugCheckEx(SPIN_LOCK_NOT_OWNED, (ULONG_PTR)SpinLock, 0, 0, 0);
86 }
87#endif
88
89#if defined(CONFIG_SMP) || DBG
90 /* Clear the lock */
91#ifdef _WIN64
93#else
95#endif
96#endif
97
98 /* Add an explicit memory barrier to prevent the compiler from reordering
99 memory accesses across the borders of spinlocks */
101}
__int64 * PLONG64
Definition: basetsd.h:183
#define InterlockedAnd64
Definition: interlocked.h:87
#define InterlockedAnd
Definition: interlocked.h:62