mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-30 12:23:28 +00:00
- Add IN/OUT annotations for KeWaitForSIngleObject
- Set the wait block outside the loop, small optimization in case we get alerted by an APC and have to loop again. - Set the wait block pointer in the KTHREAD structure only *after* checking if a wait is actually needed. That way, if the object is already signaled, we don't set anything in the WaitBlockList. - Small optimization: only set the caller's WAitBlock as the next wait block if a timer wasn't specificed, else we ended up overwriting the value. - Small optimziation: don't write the thread in the wait block, this is a wait for a signle object so this isn't needed. svn path=/trunk/; revision=23063
This commit is contained in:
+14
-11
@@ -379,11 +379,11 @@ KeDelayExecutionThread(IN KPROCESSOR_MODE WaitMode,
|
||||
*/
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
KeWaitForSingleObject(PVOID Object,
|
||||
KWAIT_REASON WaitReason,
|
||||
KPROCESSOR_MODE WaitMode,
|
||||
BOOLEAN Alertable,
|
||||
PLARGE_INTEGER Timeout)
|
||||
KeWaitForSingleObject(IN PVOID Object,
|
||||
IN KWAIT_REASON WaitReason,
|
||||
IN KPROCESSOR_MODE WaitMode,
|
||||
IN BOOLEAN Alertable,
|
||||
IN PLARGE_INTEGER Timeout OPTIONAL)
|
||||
{
|
||||
PKMUTANT CurrentObject;
|
||||
PKWAIT_BLOCK WaitBlock;
|
||||
@@ -406,6 +406,7 @@ KeWaitForSingleObject(PVOID Object,
|
||||
}
|
||||
|
||||
/* Start the actual Loop */
|
||||
WaitBlock = &CurrentThread->WaitBlock[0];
|
||||
do
|
||||
{
|
||||
/* Check if a kernel APC is pending and we're below APC_LEVEL */
|
||||
@@ -421,10 +422,6 @@ KeWaitForSingleObject(PVOID Object,
|
||||
/* Set default status */
|
||||
CurrentThread->WaitStatus = STATUS_WAIT_0;
|
||||
|
||||
/* Append wait block to the KTHREAD wait block list */
|
||||
WaitBlock = &CurrentThread->WaitBlock[0];
|
||||
CurrentThread->WaitBlockList = WaitBlock;
|
||||
|
||||
/* Get the Current Object */
|
||||
CurrentObject = (PKMUTANT)Object;
|
||||
|
||||
@@ -460,12 +457,13 @@ KeWaitForSingleObject(PVOID Object,
|
||||
goto DontWait;
|
||||
}
|
||||
|
||||
/* Append wait block to the KTHREAD wait block list */
|
||||
CurrentThread->WaitBlockList = WaitBlock;
|
||||
|
||||
/* Set up the Wait Block */
|
||||
WaitBlock->Object = CurrentObject;
|
||||
WaitBlock->Thread = CurrentThread;
|
||||
WaitBlock->WaitKey = (USHORT)(STATUS_SUCCESS);
|
||||
WaitBlock->WaitType = WaitAny;
|
||||
WaitBlock->NextWaitBlock = WaitBlock;
|
||||
|
||||
/* Make sure we can satisfy the Alertable request */
|
||||
KiCheckAlertability();
|
||||
@@ -509,6 +507,11 @@ KeWaitForSingleObject(PVOID Object,
|
||||
goto DontWait;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No timer block, so just set our wait block as next */
|
||||
WaitBlock->NextWaitBlock = WaitBlock;
|
||||
}
|
||||
|
||||
/* Link the Object to this Wait Block */
|
||||
InsertTailList(&CurrentObject->Header.WaitListHead,
|
||||
|
||||
Reference in New Issue
Block a user