mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-02 04:13:34 +00:00
- Cleanup + formatting fixes for wait.c
- Move some inlined functions from ke.h to ke_x.h - Add checks for special apc disabled (guarded regions) in wait code. svn path=/trunk/; revision=23050
This commit is contained in:
@@ -79,99 +79,6 @@ extern ULONG KeI386FxsrPresent;
|
||||
InitializeListHead(&((Header)->WaitListHead)); \
|
||||
}
|
||||
|
||||
/* The following macro satisfies the wait of any dispatcher object */
|
||||
#define KiSatisfyObjectWait(Object, Thread) \
|
||||
{ \
|
||||
/* Special case for Mutants */ \
|
||||
if ((Object)->Header.Type == MutantObject) \
|
||||
{ \
|
||||
/* Decrease the Signal State */ \
|
||||
(Object)->Header.SignalState--; \
|
||||
\
|
||||
/* Check if it's now non-signaled */ \
|
||||
if (!(Object)->Header.SignalState) \
|
||||
{ \
|
||||
/* Set the Owner Thread */ \
|
||||
(Object)->OwnerThread = Thread; \
|
||||
\
|
||||
/* Disable APCs if needed */ \
|
||||
Thread->KernelApcDisable -= (Object)->ApcDisable; \
|
||||
\
|
||||
/* Check if it's abandoned */ \
|
||||
if ((Object)->Abandoned) \
|
||||
{ \
|
||||
/* Unabandon it */ \
|
||||
(Object)->Abandoned = FALSE; \
|
||||
\
|
||||
/* Return Status */ \
|
||||
Thread->WaitStatus = STATUS_ABANDONED; \
|
||||
} \
|
||||
\
|
||||
/* Insert it into the Mutant List */ \
|
||||
InsertHeadList(&Thread->MutantListHead, \
|
||||
&(Object)->MutantListEntry); \
|
||||
} \
|
||||
} \
|
||||
else if (((Object)->Header.Type & TIMER_OR_EVENT_TYPE) == \
|
||||
EventSynchronizationObject) \
|
||||
{ \
|
||||
/* Synchronization Timers and Events just get un-signaled */ \
|
||||
(Object)->Header.SignalState = 0; \
|
||||
} \
|
||||
else if ((Object)->Header.Type == SemaphoreObject) \
|
||||
{ \
|
||||
/* These ones can have multiple states, so we only decrease it */ \
|
||||
(Object)->Header.SignalState--; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* The following macro satisfies the wait of a mutant dispatcher object */
|
||||
#define KiSatisfyMutantWait(Object, Thread) \
|
||||
{ \
|
||||
/* Decrease the Signal State */ \
|
||||
(Object)->Header.SignalState--; \
|
||||
\
|
||||
/* Check if it's now non-signaled */ \
|
||||
if (!(Object)->Header.SignalState) \
|
||||
{ \
|
||||
/* Set the Owner Thread */ \
|
||||
(Object)->OwnerThread = Thread; \
|
||||
\
|
||||
/* Disable APCs if needed */ \
|
||||
Thread->KernelApcDisable -= (Object)->ApcDisable; \
|
||||
\
|
||||
/* Check if it's abandoned */ \
|
||||
if ((Object)->Abandoned) \
|
||||
{ \
|
||||
/* Unabandon it */ \
|
||||
(Object)->Abandoned = FALSE; \
|
||||
\
|
||||
/* Return Status */ \
|
||||
Thread->WaitStatus = STATUS_ABANDONED; \
|
||||
} \
|
||||
\
|
||||
/* Insert it into the Mutant List */ \
|
||||
InsertHeadList(&Thread->MutantListHead, \
|
||||
&(Object)->MutantListEntry); \
|
||||
} \
|
||||
}
|
||||
|
||||
/* The following macro satisfies the wait of any nonmutant dispatcher object */
|
||||
#define KiSatisfyNonMutantWait(Object, Thread) \
|
||||
{ \
|
||||
if (((Object)->Header.Type & TIMER_OR_EVENT_TYPE) == \
|
||||
EventSynchronizationObject) \
|
||||
{ \
|
||||
/* Synchronization Timers and Events just get un-signaled */ \
|
||||
(Object)->Header.SignalState = 0; \
|
||||
} \
|
||||
else if ((Object)->Header.Type == SemaphoreObject) \
|
||||
{ \
|
||||
/* These ones can have multiple states, so we only decrease it */ \
|
||||
(Object)->Header.SignalState--; \
|
||||
} \
|
||||
}
|
||||
|
||||
extern KSPIN_LOCK DispatcherDatabaseLock;
|
||||
|
||||
#define KeEnterCriticalRegion() \
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
//
|
||||
// Guarded Region Routines
|
||||
// Enters a Critical Region
|
||||
//
|
||||
#define KeEnterGuardedRegion() \
|
||||
{ \
|
||||
@@ -23,6 +23,9 @@
|
||||
Thread->SpecialApcDisable--; \
|
||||
}
|
||||
|
||||
//
|
||||
// Leaves a Critical Region
|
||||
//
|
||||
#define KeLeaveGuardedRegion() \
|
||||
{ \
|
||||
PKTHREAD Thread = KeGetCurrentThread(); \
|
||||
@@ -54,6 +57,142 @@
|
||||
//
|
||||
|
||||
//
|
||||
// TODO: Wait Routines
|
||||
// Satisfies the wait of any dispatcher object
|
||||
//
|
||||
#define KiSatisfyObjectWait(Object, Thread) \
|
||||
{ \
|
||||
/* Special case for Mutants */ \
|
||||
if ((Object)->Header.Type == MutantObject) \
|
||||
{ \
|
||||
/* Decrease the Signal State */ \
|
||||
(Object)->Header.SignalState--; \
|
||||
\
|
||||
/* Check if it's now non-signaled */ \
|
||||
if (!(Object)->Header.SignalState) \
|
||||
{ \
|
||||
/* Set the Owner Thread */ \
|
||||
(Object)->OwnerThread = Thread; \
|
||||
\
|
||||
/* Disable APCs if needed */ \
|
||||
Thread->KernelApcDisable -= (Object)->ApcDisable; \
|
||||
\
|
||||
/* Check if it's abandoned */ \
|
||||
if ((Object)->Abandoned) \
|
||||
{ \
|
||||
/* Unabandon it */ \
|
||||
(Object)->Abandoned = FALSE; \
|
||||
\
|
||||
/* Return Status */ \
|
||||
Thread->WaitStatus = STATUS_ABANDONED; \
|
||||
} \
|
||||
\
|
||||
/* Insert it into the Mutant List */ \
|
||||
InsertHeadList(&Thread->MutantListHead, \
|
||||
&(Object)->MutantListEntry); \
|
||||
} \
|
||||
} \
|
||||
else if (((Object)->Header.Type & TIMER_OR_EVENT_TYPE) == \
|
||||
EventSynchronizationObject) \
|
||||
{ \
|
||||
/* Synchronization Timers and Events just get un-signaled */ \
|
||||
(Object)->Header.SignalState = 0; \
|
||||
} \
|
||||
else if ((Object)->Header.Type == SemaphoreObject) \
|
||||
{ \
|
||||
/* These ones can have multiple states, so we only decrease it */ \
|
||||
(Object)->Header.SignalState--; \
|
||||
} \
|
||||
}
|
||||
|
||||
//
|
||||
// Satisfies the wait of a mutant dispatcher object
|
||||
//
|
||||
#define KiSatisfyMutantWait(Object, Thread) \
|
||||
{ \
|
||||
/* Decrease the Signal State */ \
|
||||
(Object)->Header.SignalState--; \
|
||||
\
|
||||
/* Check if it's now non-signaled */ \
|
||||
if (!(Object)->Header.SignalState) \
|
||||
{ \
|
||||
/* Set the Owner Thread */ \
|
||||
(Object)->OwnerThread = Thread; \
|
||||
\
|
||||
/* Disable APCs if needed */ \
|
||||
Thread->KernelApcDisable -= (Object)->ApcDisable; \
|
||||
\
|
||||
/* Check if it's abandoned */ \
|
||||
if ((Object)->Abandoned) \
|
||||
{ \
|
||||
/* Unabandon it */ \
|
||||
(Object)->Abandoned = FALSE; \
|
||||
\
|
||||
/* Return Status */ \
|
||||
Thread->WaitStatus = STATUS_ABANDONED; \
|
||||
} \
|
||||
\
|
||||
/* Insert it into the Mutant List */ \
|
||||
InsertHeadList(&Thread->MutantListHead, \
|
||||
&(Object)->MutantListEntry); \
|
||||
} \
|
||||
}
|
||||
|
||||
//
|
||||
// Satisfies the wait of any nonmutant dispatcher object
|
||||
//
|
||||
#define KiSatisfyNonMutantWait(Object, Thread) \
|
||||
{ \
|
||||
if (((Object)->Header.Type & TIMER_OR_EVENT_TYPE) == \
|
||||
EventSynchronizationObject) \
|
||||
{ \
|
||||
/* Synchronization Timers and Events just get un-signaled */ \
|
||||
(Object)->Header.SignalState = 0; \
|
||||
} \
|
||||
else if ((Object)->Header.Type == SemaphoreObject) \
|
||||
{ \
|
||||
/* These ones can have multiple states, so we only decrease it */ \
|
||||
(Object)->Header.SignalState--; \
|
||||
} \
|
||||
}
|
||||
|
||||
//
|
||||
// Rules for checking alertability:
|
||||
// - For Alertable waits ONLY:
|
||||
// * We don't wait and return STATUS_ALERTED if the thread is alerted
|
||||
// in EITHER the specified wait mode OR in Kernel Mode.
|
||||
// - For BOTH Alertable AND Non-Alertable waits:
|
||||
// * We don't want and return STATUS_USER_APC if the User Mode APC list
|
||||
// is not empty AND the wait mode is User Mode.
|
||||
//
|
||||
#define KiCheckAlertability() \
|
||||
{ \
|
||||
if (Alertable) \
|
||||
{ \
|
||||
if (CurrentThread->Alerted[(int)WaitMode]) \
|
||||
{ \
|
||||
CurrentThread->Alerted[(int)WaitMode] = FALSE; \
|
||||
WaitStatus = STATUS_ALERTED; \
|
||||
break; \
|
||||
} \
|
||||
else if ((WaitMode != KernelMode) && \
|
||||
(!IsListEmpty(&CurrentThread-> \
|
||||
ApcState.ApcListHead[UserMode]))) \
|
||||
{ \
|
||||
CurrentThread->ApcState.UserApcPending = TRUE; \
|
||||
WaitStatus = STATUS_USER_APC; \
|
||||
break; \
|
||||
} \
|
||||
else if (CurrentThread->Alerted[KernelMode]) \
|
||||
{ \
|
||||
CurrentThread->Alerted[KernelMode] = FALSE; \
|
||||
WaitStatus = STATUS_ALERTED; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
else if ((WaitMode != KernelMode) && \
|
||||
(CurrentThread->ApcState.UserApcPending)) \
|
||||
{ \
|
||||
WaitStatus = STATUS_USER_APC; \
|
||||
break; \
|
||||
} \
|
||||
}
|
||||
|
||||
+559
-645
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user