mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
added KiAcquire/ReleaseSpinLock
svn path=/trunk/; revision=7759
This commit is contained in:
parent
68ac8c2fb9
commit
f3c9b196a6
4 changed files with 67 additions and 41 deletions
|
@ -10,6 +10,10 @@
|
|||
|
||||
VOID STDCALL KeAttachProcess (struct _EPROCESS* Process);
|
||||
|
||||
VOID FASTCALL KiAcquireSpinLock(PKSPIN_LOCK SpinLock);
|
||||
|
||||
VOID FASTCALL KiReleaseSpinLock(PKSPIN_LOCK SpinLock);
|
||||
|
||||
VOID KeDrainApcQueue(VOID);
|
||||
struct _KPROCESS* KeGetCurrentProcess(VOID);
|
||||
|
||||
|
@ -516,8 +520,8 @@ KfReleaseSpinLock (
|
|||
|
||||
|
||||
VOID STDCALL KiDeliverApc(ULONG Unknown1,
|
||||
ULONG Unknown2,
|
||||
ULONG Unknown3);
|
||||
ULONG Unknown2,
|
||||
ULONG Unknown3);
|
||||
|
||||
VOID STDCALL KiDispatchInterrupt(VOID);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: spinlock.c,v 1.19 2003/09/25 15:54:42 navaraf Exp $
|
||||
/* $Id: spinlock.c,v 1.20 2004/01/18 22:41:53 gdalsnes Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -44,12 +44,12 @@ KeSynchronizeExecution (PKINTERRUPT Interrupt,
|
|||
KIRQL oldlvl;
|
||||
BOOLEAN ret;
|
||||
|
||||
KeRaiseIrql(Interrupt->SynchLevel,&oldlvl);
|
||||
KeAcquireSpinLockAtDpcLevel(Interrupt->IrqLock);
|
||||
KeRaiseIrql(Interrupt->SynchLevel, &oldlvl);
|
||||
KiAcquireSpinLock(Interrupt->IrqLock);
|
||||
|
||||
ret = SynchronizeRoutine(SynchronizeContext);
|
||||
|
||||
KeReleaseSpinLockFromDpcLevel(Interrupt->IrqLock);
|
||||
KiReleaseSpinLock(Interrupt->IrqLock);
|
||||
KeLowerIrql(oldlvl);
|
||||
|
||||
return(ret);
|
||||
|
@ -77,27 +77,8 @@ KeInitializeSpinLock (PKSPIN_LOCK SpinLock)
|
|||
VOID FASTCALL
|
||||
KefAcquireSpinLockAtDpcLevel(PKSPIN_LOCK SpinLock)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
/*
|
||||
* FIXME: This depends on gcc assembling this test to a single load from
|
||||
* the spinlock's value.
|
||||
*/
|
||||
if (*SpinLock >= 2)
|
||||
{
|
||||
DbgPrint("Lock %x has bad value %x\n", SpinLock, *SpinLock);
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
|
||||
while ((i = InterlockedExchange((LONG *)SpinLock, 1)) == 1)
|
||||
{
|
||||
#ifndef MP
|
||||
DbgPrint("Spinning on spinlock %x current value %x\n", SpinLock, i);
|
||||
KEBUGCHECK(0);
|
||||
#else /* not MP */
|
||||
/* Avoid reading the value again too fast */
|
||||
#endif /* MP */
|
||||
}
|
||||
assert(KeGetCurrentIrql() == DISPATCH_LEVEL);
|
||||
KiAcquireSpinLock(SpinLock);
|
||||
}
|
||||
|
||||
#undef KeAcquireSpinLockAtDpcLevel
|
||||
|
@ -114,7 +95,7 @@ KeAcquireSpinLockAtDpcLevel (PKSPIN_LOCK SpinLock)
|
|||
* SpinLock = Spinlock to acquire
|
||||
*/
|
||||
{
|
||||
KefAcquireSpinLockAtDpcLevel(SpinLock);
|
||||
KefAcquireSpinLockAtDpcLevel(SpinLock);
|
||||
}
|
||||
|
||||
#undef KefReleaseSpinLockFromDpcLevel
|
||||
|
@ -125,12 +106,8 @@ KeAcquireSpinLockAtDpcLevel (PKSPIN_LOCK SpinLock)
|
|||
VOID FASTCALL
|
||||
KefReleaseSpinLockFromDpcLevel(PKSPIN_LOCK SpinLock)
|
||||
{
|
||||
if (*SpinLock != 1)
|
||||
{
|
||||
DbgPrint("Releasing unacquired spinlock %x\n", SpinLock);
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
(void)InterlockedExchange((LONG *)SpinLock, 0);
|
||||
assert(KeGetCurrentIrql() == DISPATCH_LEVEL);
|
||||
KiReleaseSpinLock(SpinLock);
|
||||
}
|
||||
|
||||
#undef KeReleaseSpinLockFromDpcLevel
|
||||
|
@ -147,7 +124,52 @@ KeReleaseSpinLockFromDpcLevel (PKSPIN_LOCK SpinLock)
|
|||
* SpinLock = Spinlock to release
|
||||
*/
|
||||
{
|
||||
KefReleaseSpinLockFromDpcLevel(SpinLock);
|
||||
KefReleaseSpinLockFromDpcLevel(SpinLock);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
VOID FASTCALL
|
||||
KiAcquireSpinLock(PKSPIN_LOCK SpinLock)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
/*
|
||||
* FIXME: This depends on gcc assembling this test to a single load from
|
||||
* the spinlock's value.
|
||||
*/
|
||||
if (*SpinLock >= 2)
|
||||
{
|
||||
DbgPrint("Lock %x has bad value %x\n", SpinLock, *SpinLock);
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
|
||||
while ((i = InterlockedExchange((LONG *)SpinLock, 1)) == 1)
|
||||
{
|
||||
#ifndef MP
|
||||
DbgPrint("Spinning on spinlock %x current value %x\n", SpinLock, i);
|
||||
KEBUGCHECK(0);
|
||||
#else /* not MP */
|
||||
/* Avoid reading the value again too fast */
|
||||
#endif /* MP */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
VOID FASTCALL
|
||||
KiReleaseSpinLock(PKSPIN_LOCK SpinLock)
|
||||
{
|
||||
if (*SpinLock != 1)
|
||||
{
|
||||
DbgPrint("Releasing unacquired spinlock %x\n", SpinLock);
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
(void)InterlockedExchange((LONG *)SpinLock, 0);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: ntoskrnl.def,v 1.171 2003/12/31 05:33:03 jfilby Exp $
|
||||
; $Id: ntoskrnl.def,v 1.172 2004/01/18 22:34:05 gdalsnes Exp $
|
||||
;
|
||||
; reactos/ntoskrnl/ntoskrnl.def
|
||||
;
|
||||
|
@ -475,14 +475,14 @@ KeWaitForSingleObject@20
|
|||
;@KefAcquireSpinLockAtDpcLevel
|
||||
;@KefReleaseSpinLockFromDpcLevel
|
||||
;Kei386EoiHelper
|
||||
;@KiAcquireSpinLock@4
|
||||
@KiAcquireSpinLock@4
|
||||
;KiBugCheckData DATA
|
||||
;KiCoprocessorError@0
|
||||
KiDeliverApc@12
|
||||
KiDispatchInterrupt@0
|
||||
KiInterruptDispatch2@8
|
||||
;KiIpiServiceRoutine@8
|
||||
;@KiReleaseSpinLock@4
|
||||
@KiReleaseSpinLock@4
|
||||
;KiUnexpectedInterrupt
|
||||
;Kii386SpinOnSpinLock
|
||||
KiRawTicks DATA
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: ntoskrnl.edf,v 1.158 2003/12/31 05:33:03 jfilby Exp $
|
||||
; $Id: ntoskrnl.edf,v 1.159 2004/01/18 22:34:05 gdalsnes Exp $
|
||||
;
|
||||
; reactos/ntoskrnl/ntoskrnl.def
|
||||
;
|
||||
|
@ -476,14 +476,14 @@ KeWaitForSingleObject=KeWaitForSingleObject@20
|
|||
KefAcquireSpinLockAtDpcLevel=@KefAcquireSpinLockAtDpcLevel@4
|
||||
KefReleaseSpinLockFromDpcLevel=@KefReleaseSpinLockFromDpcLevel@4
|
||||
;Kei386EoiHelper
|
||||
;KiAcquireSpinLock@4
|
||||
KiAcquireSpinLock=@KiAcquireSpinLock@4
|
||||
;KiBugCheckData DATA
|
||||
;KiCoprocessorError@0
|
||||
KiDeliverApc=KiDeliverApc@12
|
||||
KiDispatchInterrupt=KiDispatchInterrupt@0
|
||||
KiInterruptDispatch2=KiInterruptDispatch2@8
|
||||
;KiIpiServiceRoutine@8
|
||||
;KiReleaseSpinLock@4
|
||||
KiReleaseSpinLock=@KiReleaseSpinLock@4
|
||||
;KiUnexpectedInterrupt
|
||||
;Kii386SpinOnSpinLock
|
||||
KiRawTicks DATA
|
||||
|
|
Loading…
Reference in a new issue