mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-03 12:23:25 +00:00
- Add ASSERT_EVENT.
- Same changes to event.c as with the other files. - Remove lock property, these files have already been audited as clean and were unlocked. svn path=/trunk/; revision=24040
This commit is contained in:
@@ -1232,6 +1232,10 @@ typedef struct _KTIMER {
|
||||
#define ASSERT_SEMAPHORE(E) \
|
||||
ASSERT((E)->Header.Type == SemaphoreObject)
|
||||
|
||||
#define ASSERT_EVENT(E) \
|
||||
ASSERT(((E)->Header.Type == NotificationEvent) || \
|
||||
((E)->Header.Type == SynchronizationEvent))
|
||||
|
||||
typedef struct _KMUTANT {
|
||||
DISPATCHER_HEADER Header;
|
||||
LIST_ENTRY MutantListEntry;
|
||||
|
||||
+79
-79
@@ -1,30 +1,27 @@
|
||||
/*
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* PROJECT: ReactOS Kernel
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: ntoskrnl/ke/event.c
|
||||
* PURPOSE: Implements events
|
||||
*
|
||||
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
||||
* David Welch (welch@mcmail.com)
|
||||
* PURPOSE: Implements the Event Dispatcher Object
|
||||
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ntoskrnl.h>
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
STDCALL
|
||||
KeClearEvent(PKEVENT Event)
|
||||
NTAPI
|
||||
KeClearEvent(IN PKEVENT Event)
|
||||
{
|
||||
DPRINT("KeClearEvent(Event %x)\n", Event);
|
||||
ASSERT_EVENT(Event);
|
||||
|
||||
/* Reset Signal State */
|
||||
Event->Header.SignalState = FALSE;
|
||||
@@ -34,13 +31,11 @@ KeClearEvent(PKEVENT Event)
|
||||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
STDCALL
|
||||
KeInitializeEvent(PKEVENT Event,
|
||||
EVENT_TYPE Type,
|
||||
BOOLEAN State)
|
||||
NTAPI
|
||||
KeInitializeEvent(IN PKEVENT Event,
|
||||
IN EVENT_TYPE Type,
|
||||
IN BOOLEAN State)
|
||||
{
|
||||
DPRINT("KeInitializeEvent(Event %x)\n", Event);
|
||||
|
||||
/* Initialize the Dispatcher Header */
|
||||
KeInitializeDispatcherHeader(&Event->Header,
|
||||
Type,
|
||||
@@ -52,11 +47,9 @@ KeInitializeEvent(PKEVENT Event,
|
||||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
STDCALL
|
||||
KeInitializeEventPair(PKEVENT_PAIR EventPair)
|
||||
NTAPI
|
||||
KeInitializeEventPair(IN PKEVENT_PAIR EventPair)
|
||||
{
|
||||
DPRINT("KeInitializeEventPair(Event %x)\n", EventPair);
|
||||
|
||||
/* Initialize the Event Pair Type and Size */
|
||||
EventPair->Type = EventPairObject;
|
||||
EventPair->Size = sizeof(KEVENT_PAIR);
|
||||
@@ -69,15 +62,17 @@ KeInitializeEventPair(PKEVENT_PAIR EventPair)
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
LONG STDCALL
|
||||
LONG
|
||||
NTAPI
|
||||
KePulseEvent(IN PKEVENT Event,
|
||||
IN KPRIORITY Increment,
|
||||
IN BOOLEAN Wait)
|
||||
{
|
||||
KIRQL OldIrql;
|
||||
LONG PreviousState;
|
||||
|
||||
DPRINT("KePulseEvent(Event %x, Wait %x)\n",Event,Wait);
|
||||
PKTHREAD Thread;
|
||||
ASSERT_EVENT(Event);
|
||||
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
|
||||
|
||||
/* Lock the Dispatcher Database */
|
||||
OldIrql = KiAcquireDispatcherLock();
|
||||
@@ -86,8 +81,8 @@ KePulseEvent(IN PKEVENT Event,
|
||||
PreviousState = Event->Header.SignalState;
|
||||
|
||||
/* Check if we are non-signaled and we have stuff in the Wait Queue */
|
||||
if (!PreviousState && !IsListEmpty(&Event->Header.WaitListHead)) {
|
||||
|
||||
if (!PreviousState && !IsListEmpty(&Event->Header.WaitListHead))
|
||||
{
|
||||
/* Set the Event to Signaled */
|
||||
Event->Header.SignalState = 1;
|
||||
|
||||
@@ -99,15 +94,15 @@ KePulseEvent(IN PKEVENT Event,
|
||||
Event->Header.SignalState = 0;
|
||||
|
||||
/* Check what wait state was requested */
|
||||
if (Wait == FALSE) {
|
||||
|
||||
if (Wait == FALSE)
|
||||
{
|
||||
/* Wait not requested, release Dispatcher Database and return */
|
||||
KiReleaseDispatcherLock(OldIrql);
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Return Locked and with a Wait */
|
||||
KTHREAD *Thread = KeGetCurrentThread();
|
||||
Thread = KeGetCurrentThread();
|
||||
Thread->WaitNext = TRUE;
|
||||
Thread->WaitIrql = OldIrql;
|
||||
}
|
||||
@@ -120,9 +115,11 @@ KePulseEvent(IN PKEVENT Event,
|
||||
* @implemented
|
||||
*/
|
||||
LONG
|
||||
STDCALL
|
||||
KeReadStateEvent(PKEVENT Event)
|
||||
NTAPI
|
||||
KeReadStateEvent(IN PKEVENT Event)
|
||||
{
|
||||
ASSERT_EVENT(Event);
|
||||
|
||||
/* Return the Signal State */
|
||||
return Event->Header.SignalState;
|
||||
}
|
||||
@@ -131,13 +128,13 @@ KeReadStateEvent(PKEVENT Event)
|
||||
* @implemented
|
||||
*/
|
||||
LONG
|
||||
STDCALL
|
||||
KeResetEvent(PKEVENT Event)
|
||||
NTAPI
|
||||
KeResetEvent(IN PKEVENT Event)
|
||||
{
|
||||
KIRQL OldIrql;
|
||||
LONG PreviousState;
|
||||
|
||||
DPRINT("KeResetEvent(Event %x)\n",Event);
|
||||
ASSERT_EVENT(Event);
|
||||
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
|
||||
|
||||
/* Lock the Dispatcher Database */
|
||||
OldIrql = KiAcquireDispatcherLock();
|
||||
@@ -157,16 +154,17 @@ KeResetEvent(PKEVENT Event)
|
||||
* @implemented
|
||||
*/
|
||||
LONG
|
||||
STDCALL
|
||||
KeSetEvent(PKEVENT Event,
|
||||
KPRIORITY Increment,
|
||||
BOOLEAN Wait)
|
||||
NTAPI
|
||||
KeSetEvent(IN PKEVENT Event,
|
||||
IN KPRIORITY Increment,
|
||||
IN BOOLEAN Wait)
|
||||
{
|
||||
KIRQL OldIrql;
|
||||
LONG PreviousState;
|
||||
PKWAIT_BLOCK WaitBlock;
|
||||
|
||||
DPRINT("KeSetEvent(Event %x, Wait %x)\n",Event,Wait);
|
||||
PKTHREAD Thread;
|
||||
ASSERT_EVENT(Event);
|
||||
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
|
||||
|
||||
/* Lock the Dispathcer Database */
|
||||
OldIrql = KiAcquireDispatcherLock();
|
||||
@@ -175,55 +173,53 @@ KeSetEvent(PKEVENT Event,
|
||||
PreviousState = Event->Header.SignalState;
|
||||
|
||||
/* Check if we have stuff in the Wait Queue */
|
||||
if (IsListEmpty(&Event->Header.WaitListHead)) {
|
||||
|
||||
if (IsListEmpty(&Event->Header.WaitListHead))
|
||||
{
|
||||
/* Set the Event to Signaled */
|
||||
DPRINT("Empty Wait Queue, Signal the Event\n");
|
||||
Event->Header.SignalState = 1;
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the Wait Block */
|
||||
WaitBlock = CONTAINING_RECORD(Event->Header.WaitListHead.Flink,
|
||||
KWAIT_BLOCK,
|
||||
WaitListEntry);
|
||||
|
||||
|
||||
/* Check the type of event */
|
||||
if (Event->Header.Type == NotificationEvent || WaitBlock->WaitType == WaitAll) {
|
||||
|
||||
if (PreviousState == 0) {
|
||||
|
||||
if ((Event->Header.Type == NotificationEvent) || (WaitBlock->WaitType == WaitAll))
|
||||
{
|
||||
/* Check if it wasn't signaled */
|
||||
if (!PreviousState)
|
||||
{
|
||||
/* We must do a full wait satisfaction */
|
||||
DPRINT("Notification Event or WaitAll, Wait on the Event and Signal\n");
|
||||
Event->Header.SignalState = 1;
|
||||
KiWaitTest(&Event->Header, Increment);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/* We can satisfy wait simply by waking the thread, since our signal state is 0 now */
|
||||
DPRINT("WaitAny or Sync Event, just unwait the thread\n");
|
||||
KiAbortWaitThread(WaitBlock->Thread, WaitBlock->WaitKey, Increment);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We can satisfy wait simply by waking the thread */
|
||||
KiAbortWaitThread(WaitBlock->Thread,
|
||||
WaitBlock->WaitKey,
|
||||
Increment);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check what wait state was requested */
|
||||
if (Wait == FALSE) {
|
||||
|
||||
if (!Wait)
|
||||
{
|
||||
/* Wait not requested, release Dispatcher Database and return */
|
||||
KiReleaseDispatcherLock(OldIrql);
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Return Locked and with a Wait */
|
||||
KTHREAD *Thread = KeGetCurrentThread();
|
||||
Thread = KeGetCurrentThread();
|
||||
Thread->WaitNext = TRUE;
|
||||
Thread->WaitIrql = OldIrql;
|
||||
}
|
||||
|
||||
/* Return the previous State */
|
||||
DPRINT("Done: %d\n", PreviousState);
|
||||
return PreviousState;
|
||||
}
|
||||
|
||||
@@ -231,32 +227,36 @@ KeSetEvent(PKEVENT Event,
|
||||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
STDCALL
|
||||
NTAPI
|
||||
KeSetEventBoostPriority(IN PKEVENT Event,
|
||||
IN PKTHREAD *Thread OPTIONAL)
|
||||
{
|
||||
PKTHREAD WaitingThread;
|
||||
KIRQL OldIrql;
|
||||
ASSERT_EVENT(Event);
|
||||
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
|
||||
|
||||
DPRINT("KeSetEventBoostPriority(Event %x, Thread %x)\n",Event,Thread);
|
||||
//
|
||||
// FIXME: This is half-broken, there's no boosting!
|
||||
//
|
||||
|
||||
/* Acquire Dispatcher Database Lock */
|
||||
OldIrql = KiAcquireDispatcherLock();
|
||||
|
||||
/* If our wait list is empty, then signal the event and return */
|
||||
if (IsListEmpty(&Event->Header.WaitListHead)) {
|
||||
|
||||
if (IsListEmpty(&Event->Header.WaitListHead))
|
||||
{
|
||||
Event->Header.SignalState = 1;
|
||||
|
||||
} else {
|
||||
|
||||
/* Get Thread that is currently waiting. First get the Wait Block, then the Thread */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the waiting thread */
|
||||
WaitingThread = CONTAINING_RECORD(Event->Header.WaitListHead.Flink,
|
||||
KWAIT_BLOCK,
|
||||
WaitListEntry)->Thread;
|
||||
|
||||
/* Return it to caller if requested */
|
||||
if ARGUMENT_PRESENT(Thread) *Thread = WaitingThread;
|
||||
if (Thread) *Thread = WaitingThread;
|
||||
|
||||
/* Reset the Quantum and Unwait the Thread */
|
||||
WaitingThread->Quantum = WaitingThread->QuantumReset;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ntoskrnl.h>
|
||||
#define NDEBUG
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ntoskrnl.h>
|
||||
#define NDEBUG
|
||||
|
||||
Reference in New Issue
Block a user