2011-08-05 21:07:52 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS kernel-mode tests
|
|
|
|
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
|
|
|
* PURPOSE: Kernel-Mode Test Suite Event test
|
2013-10-12 16:05:54 +00:00
|
|
|
* PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
|
2011-08-05 21:07:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <kmt_test.h>
|
|
|
|
|
2011-08-10 13:49:36 +00:00
|
|
|
#define CheckEvent(Event, ExpectedType, State, ExpectedWaitNext, \
|
|
|
|
Irql, ThreadList, ThreadCount) do \
|
2011-08-05 21:07:52 +00:00
|
|
|
{ \
|
2011-08-10 13:49:36 +00:00
|
|
|
INT TheIndex; \
|
|
|
|
PLIST_ENTRY TheEntry; \
|
|
|
|
PKTHREAD TheThread; \
|
2011-08-05 21:07:52 +00:00
|
|
|
ok_eq_uint((Event)->Header.Type, ExpectedType); \
|
|
|
|
ok_eq_uint((Event)->Header.Hand, sizeof *(Event) / sizeof(ULONG)); \
|
2011-08-10 13:49:36 +00:00
|
|
|
ok_eq_hex((Event)->Header.Lock & 0xFF00FF00L, 0x55005500L); \
|
2011-08-05 21:07:52 +00:00
|
|
|
ok_eq_long((Event)->Header.SignalState, State); \
|
2011-08-10 13:49:36 +00:00
|
|
|
TheEntry = (Event)->Header.WaitListHead.Flink; \
|
|
|
|
for (TheIndex = 0; TheIndex < (ThreadCount); ++TheIndex) \
|
|
|
|
{ \
|
|
|
|
TheThread = CONTAINING_RECORD(TheEntry, KTHREAD, \
|
2015-09-19 12:15:16 +00:00
|
|
|
WaitBlock[0].WaitListEntry); \
|
2011-08-10 13:49:36 +00:00
|
|
|
ok_eq_pointer(TheThread, (ThreadList)[TheIndex]); \
|
|
|
|
ok_eq_pointer(TheEntry->Flink->Blink, TheEntry); \
|
|
|
|
TheEntry = TheEntry->Flink; \
|
|
|
|
} \
|
|
|
|
ok_eq_pointer(TheEntry, &(Event)->Header.WaitListHead); \
|
|
|
|
ok_eq_pointer(TheEntry->Flink->Blink, TheEntry); \
|
2011-08-05 21:07:52 +00:00
|
|
|
ok_eq_long(KeReadStateEvent(Event), State); \
|
|
|
|
ok_eq_bool(Thread->WaitNext, ExpectedWaitNext); \
|
|
|
|
ok_irql(Irql); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
static
|
|
|
|
VOID
|
|
|
|
TestEventFunctional(
|
|
|
|
IN PKEVENT Event,
|
|
|
|
IN EVENT_TYPE Type,
|
|
|
|
IN KIRQL OriginalIrql)
|
|
|
|
{
|
|
|
|
LONG State;
|
|
|
|
PKTHREAD Thread = KeGetCurrentThread();
|
|
|
|
|
|
|
|
memset(Event, 0x55, sizeof *Event);
|
|
|
|
KeInitializeEvent(Event, Type, FALSE);
|
2011-08-10 13:49:36 +00:00
|
|
|
CheckEvent(Event, Type, 0L, FALSE, OriginalIrql, (PVOID *)NULL, 0);
|
2011-08-05 21:07:52 +00:00
|
|
|
|
|
|
|
memset(Event, 0x55, sizeof *Event);
|
|
|
|
KeInitializeEvent(Event, Type, TRUE);
|
2011-08-10 13:49:36 +00:00
|
|
|
CheckEvent(Event, Type, 1L, FALSE, OriginalIrql, (PVOID *)NULL, 0);
|
2011-08-05 21:07:52 +00:00
|
|
|
|
|
|
|
Event->Header.SignalState = 0x12345678L;
|
2011-08-10 13:49:36 +00:00
|
|
|
CheckEvent(Event, Type, 0x12345678L, FALSE, OriginalIrql, (PVOID *)NULL, 0);
|
2011-08-05 21:07:52 +00:00
|
|
|
|
|
|
|
State = KePulseEvent(Event, 0, FALSE);
|
2011-08-10 13:49:36 +00:00
|
|
|
CheckEvent(Event, Type, 0L, FALSE, OriginalIrql, (PVOID *)NULL, 0);
|
2011-08-05 21:07:52 +00:00
|
|
|
ok_eq_long(State, 0x12345678L);
|
|
|
|
|
|
|
|
Event->Header.SignalState = 0x12345678L;
|
|
|
|
KeClearEvent(Event);
|
2011-08-10 13:49:36 +00:00
|
|
|
CheckEvent(Event, Type, 0L, FALSE, OriginalIrql, (PVOID *)NULL, 0);
|
2011-08-05 21:07:52 +00:00
|
|
|
|
|
|
|
State = KeSetEvent(Event, 0, FALSE);
|
2011-08-10 13:49:36 +00:00
|
|
|
CheckEvent(Event, Type, 1L, FALSE, OriginalIrql, (PVOID *)NULL, 0);
|
2011-08-05 21:07:52 +00:00
|
|
|
ok_eq_long(State, 0L);
|
|
|
|
|
|
|
|
State = KeResetEvent(Event);
|
2011-08-10 13:49:36 +00:00
|
|
|
CheckEvent(Event, Type, 0L, FALSE, OriginalIrql, (PVOID *)NULL, 0);
|
2011-08-05 21:07:52 +00:00
|
|
|
ok_eq_long(State, 1L);
|
|
|
|
|
|
|
|
Event->Header.SignalState = 0x23456789L;
|
|
|
|
State = KeSetEvent(Event, 0, FALSE);
|
2011-08-10 13:49:36 +00:00
|
|
|
CheckEvent(Event, Type, 1L, FALSE, OriginalIrql, (PVOID *)NULL, 0);
|
2011-08-05 21:07:52 +00:00
|
|
|
ok_eq_long(State, 0x23456789L);
|
|
|
|
|
|
|
|
Event->Header.SignalState = 0x3456789AL;
|
|
|
|
State = KeResetEvent(Event);
|
2011-08-10 13:49:36 +00:00
|
|
|
CheckEvent(Event, Type, 0L, FALSE, OriginalIrql, (PVOID *)NULL, 0);
|
2011-08-05 21:07:52 +00:00
|
|
|
ok_eq_long(State, 0x3456789AL);
|
|
|
|
|
2011-08-10 13:49:36 +00:00
|
|
|
/* Irql is raised to DISPATCH_LEVEL here, which kills checked build,
|
|
|
|
* a spinlock is acquired and never released, which kills MP build */
|
|
|
|
if ((OriginalIrql <= DISPATCH_LEVEL || !KmtIsCheckedBuild) &&
|
|
|
|
!KmtIsMultiProcessorBuild)
|
2011-08-05 21:07:52 +00:00
|
|
|
{
|
|
|
|
Event->Header.SignalState = 0x456789ABL;
|
|
|
|
State = KeSetEvent(Event, 0, TRUE);
|
2011-08-10 13:49:36 +00:00
|
|
|
CheckEvent(Event, Type, 1L, TRUE, DISPATCH_LEVEL, (PVOID *)NULL, 0);
|
2011-08-05 21:07:52 +00:00
|
|
|
ok_eq_long(State, 0x456789ABL);
|
|
|
|
ok_eq_uint(Thread->WaitIrql, OriginalIrql);
|
|
|
|
/* repair the "damage" */
|
|
|
|
Thread->WaitNext = FALSE;
|
|
|
|
KmtSetIrql(OriginalIrql);
|
|
|
|
|
|
|
|
Event->Header.SignalState = 0x56789ABCL;
|
|
|
|
State = KePulseEvent(Event, 0, TRUE);
|
2011-08-10 13:49:36 +00:00
|
|
|
CheckEvent(Event, Type, 0L, TRUE, DISPATCH_LEVEL, (PVOID *)NULL, 0);
|
2011-08-05 21:07:52 +00:00
|
|
|
ok_eq_long(State, 0x56789ABCL);
|
|
|
|
ok_eq_uint(Thread->WaitIrql, OriginalIrql);
|
|
|
|
/* repair the "damage" */
|
|
|
|
Thread->WaitNext = FALSE;
|
|
|
|
KmtSetIrql(OriginalIrql);
|
|
|
|
}
|
|
|
|
|
|
|
|
ok_irql(OriginalIrql);
|
|
|
|
KmtSetIrql(OriginalIrql);
|
|
|
|
}
|
|
|
|
|
2011-08-05 21:12:11 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
HANDLE Handle;
|
|
|
|
PKTHREAD Thread;
|
2011-08-10 13:49:36 +00:00
|
|
|
PKEVENT Event;
|
2011-08-05 21:12:11 +00:00
|
|
|
volatile BOOLEAN Signal;
|
|
|
|
} THREAD_DATA, *PTHREAD_DATA;
|
|
|
|
|
|
|
|
static
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
WaitForEventThread(
|
|
|
|
IN OUT PVOID Context)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
PTHREAD_DATA ThreadData = Context;
|
|
|
|
|
|
|
|
ok_irql(PASSIVE_LEVEL);
|
|
|
|
ThreadData->Signal = TRUE;
|
2011-08-10 13:49:36 +00:00
|
|
|
Status = KeWaitForSingleObject(ThreadData->Event, Executive, KernelMode, FALSE, NULL);
|
2011-08-05 21:12:11 +00:00
|
|
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
|
|
|
ok_irql(PASSIVE_LEVEL);
|
|
|
|
}
|
|
|
|
|
2011-08-10 13:49:36 +00:00
|
|
|
typedef LONG (NTAPI *PSET_EVENT_FUNCTION)(PRKEVENT, KPRIORITY, BOOLEAN);
|
|
|
|
|
2011-08-05 21:12:11 +00:00
|
|
|
static
|
|
|
|
VOID
|
2011-08-10 13:49:36 +00:00
|
|
|
TestEventConcurrent(
|
2011-08-05 21:12:11 +00:00
|
|
|
IN PKEVENT Event,
|
|
|
|
IN EVENT_TYPE Type,
|
2011-08-10 13:49:36 +00:00
|
|
|
IN KIRQL OriginalIrql,
|
|
|
|
PSET_EVENT_FUNCTION SetEvent,
|
|
|
|
KPRIORITY PriorityIncrement,
|
|
|
|
LONG ExpectedState,
|
|
|
|
BOOLEAN SatisfiesAll)
|
2011-08-05 21:12:11 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
THREAD_DATA Threads[5];
|
2011-08-10 13:49:36 +00:00
|
|
|
const INT ThreadCount = sizeof Threads / sizeof Threads[0];
|
2011-08-05 21:12:11 +00:00
|
|
|
KPRIORITY Priority;
|
2011-08-10 13:49:36 +00:00
|
|
|
LARGE_INTEGER LongTimeout, ShortTimeout;
|
|
|
|
INT i;
|
2015-09-19 12:15:16 +00:00
|
|
|
KWAIT_BLOCK WaitBlock[RTL_NUMBER_OF(Threads)];
|
|
|
|
PVOID ThreadObjects[RTL_NUMBER_OF(Threads)];
|
2011-08-10 13:49:36 +00:00
|
|
|
LONG State;
|
|
|
|
PKTHREAD Thread = KeGetCurrentThread();
|
2015-09-19 21:46:40 +00:00
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
2011-08-10 13:49:36 +00:00
|
|
|
|
|
|
|
LongTimeout.QuadPart = -100 * MILLISECOND;
|
|
|
|
ShortTimeout.QuadPart = -1 * MILLISECOND;
|
2011-08-05 21:12:11 +00:00
|
|
|
|
|
|
|
KeInitializeEvent(Event, Type, FALSE);
|
|
|
|
|
2011-08-10 13:49:36 +00:00
|
|
|
for (i = 0; i < ThreadCount; ++i)
|
2011-08-05 21:12:11 +00:00
|
|
|
{
|
2011-08-10 13:49:36 +00:00
|
|
|
Threads[i].Event = Event;
|
2011-08-05 21:12:11 +00:00
|
|
|
Threads[i].Signal = FALSE;
|
2015-09-19 21:46:40 +00:00
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
NULL,
|
|
|
|
OBJ_KERNEL_HANDLE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
Status = PsCreateSystemThread(&Threads[i].Handle, GENERIC_ALL, &ObjectAttributes, NULL, NULL, WaitForEventThread, &Threads[i]);
|
2011-08-05 21:12:11 +00:00
|
|
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
2014-05-12 23:36:05 +00:00
|
|
|
Status = ObReferenceObjectByHandle(Threads[i].Handle, SYNCHRONIZE, *PsThreadType, KernelMode, (PVOID *)&Threads[i].Thread, NULL);
|
2011-08-05 21:12:11 +00:00
|
|
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
2011-08-10 13:49:36 +00:00
|
|
|
ThreadObjects[i] = Threads[i].Thread;
|
2011-08-05 21:12:11 +00:00
|
|
|
Priority = KeQueryPriorityThread(Threads[i].Thread);
|
|
|
|
ok_eq_long(Priority, 8L);
|
|
|
|
while (!Threads[i].Signal)
|
|
|
|
{
|
2011-08-10 13:49:36 +00:00
|
|
|
Status = KeDelayExecutionThread(KernelMode, FALSE, &ShortTimeout);
|
2015-09-19 12:39:01 +00:00
|
|
|
if (Status != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
|
|
|
}
|
2011-08-05 21:12:11 +00:00
|
|
|
}
|
2011-08-10 13:49:36 +00:00
|
|
|
CheckEvent(Event, Type, 0L, FALSE, OriginalIrql, ThreadObjects, i + 1);
|
2011-08-05 21:12:11 +00:00
|
|
|
}
|
|
|
|
|
2011-08-10 13:49:36 +00:00
|
|
|
/* the threads shouldn't wake up on their own */
|
|
|
|
Status = KeDelayExecutionThread(KernelMode, FALSE, &ShortTimeout);
|
|
|
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
|
|
|
|
|
|
|
for (i = 0; i < ThreadCount; ++i)
|
2011-08-05 21:12:11 +00:00
|
|
|
{
|
2011-08-10 13:49:36 +00:00
|
|
|
CheckEvent(Event, Type, 0L, FALSE, OriginalIrql, ThreadObjects + i, ThreadCount - i);
|
|
|
|
State = SetEvent(Event, PriorityIncrement + i, FALSE);
|
|
|
|
|
|
|
|
ok_eq_long(State, 0L);
|
|
|
|
CheckEvent(Event, Type, ExpectedState, FALSE, OriginalIrql, ThreadObjects + i + 1, SatisfiesAll ? 0 : ThreadCount - i - 1);
|
|
|
|
Status = KeWaitForMultipleObjects(ThreadCount, ThreadObjects, SatisfiesAll ? WaitAll : WaitAny, Executive, KernelMode, FALSE, &LongTimeout, WaitBlock);
|
|
|
|
ok_eq_hex(Status, STATUS_WAIT_0 + i);
|
|
|
|
if (SatisfiesAll)
|
2011-08-05 21:12:11 +00:00
|
|
|
{
|
2011-08-10 13:49:36 +00:00
|
|
|
for (; i < ThreadCount; ++i)
|
|
|
|
{
|
|
|
|
Priority = KeQueryPriorityThread(Threads[i].Thread);
|
|
|
|
ok_eq_long(Priority, max(min(8L + PriorityIncrement, 15L), 8L));
|
|
|
|
}
|
|
|
|
break;
|
2011-08-05 21:12:11 +00:00
|
|
|
}
|
|
|
|
Priority = KeQueryPriorityThread(Threads[i].Thread);
|
2011-08-10 13:49:36 +00:00
|
|
|
ok_eq_long(Priority, max(min(8L + PriorityIncrement + i, 15L), 8L));
|
|
|
|
/* replace the thread with the current thread - which will never signal */
|
2019-06-03 23:14:31 +00:00
|
|
|
if (!skip((Status & 0x3F) < ThreadCount, "Index out of bounds\n"))
|
2011-08-10 13:49:36 +00:00
|
|
|
ThreadObjects[Status & 0x3F] = Thread;
|
|
|
|
Status = KeWaitForMultipleObjects(ThreadCount, ThreadObjects, WaitAny, Executive, KernelMode, FALSE, &ShortTimeout, WaitBlock);
|
|
|
|
ok_eq_hex(Status, STATUS_TIMEOUT);
|
|
|
|
}
|
2011-08-05 21:12:11 +00:00
|
|
|
|
2011-08-10 13:49:36 +00:00
|
|
|
for (i = 0; i < ThreadCount; ++i)
|
|
|
|
{
|
2011-08-05 21:12:11 +00:00
|
|
|
ObDereferenceObject(Threads[i].Thread);
|
|
|
|
Status = ZwClose(Threads[i].Handle);
|
|
|
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-19 12:57:51 +00:00
|
|
|
#define NUM_SCHED_TESTS 1000
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
KEVENT Event;
|
|
|
|
KEVENT WaitEvent;
|
|
|
|
ULONG Counter;
|
|
|
|
KPRIORITY PriorityIncrement;
|
|
|
|
ULONG CounterValues[NUM_SCHED_TESTS];
|
|
|
|
} COUNT_THREAD_DATA, *PCOUNT_THREAD_DATA;
|
|
|
|
|
|
|
|
static
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
CountThread(
|
|
|
|
IN OUT PVOID Context)
|
|
|
|
{
|
|
|
|
PCOUNT_THREAD_DATA ThreadData = Context;
|
|
|
|
PKEVENT Event = &ThreadData->Event;
|
|
|
|
volatile ULONG *Counter = &ThreadData->Counter;
|
|
|
|
ULONG *CounterValue = ThreadData->CounterValues;
|
|
|
|
KPRIORITY Priority;
|
|
|
|
|
|
|
|
Priority = KeQueryPriorityThread(KeGetCurrentThread());
|
|
|
|
ok_eq_long(Priority, 8L);
|
|
|
|
|
|
|
|
while (CounterValue < &ThreadData->CounterValues[NUM_SCHED_TESTS])
|
|
|
|
{
|
|
|
|
KeSetEvent(&ThreadData->WaitEvent, IO_NO_INCREMENT, TRUE);
|
|
|
|
KeWaitForSingleObject(Event, Executive, KernelMode, FALSE, NULL);
|
|
|
|
*CounterValue++ = *Counter;
|
|
|
|
}
|
|
|
|
|
|
|
|
Priority = KeQueryPriorityThread(KeGetCurrentThread());
|
|
|
|
ok_eq_long(Priority, 8L + min(ThreadData->PriorityIncrement, 7));
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
TestEventScheduling(
|
|
|
|
_In_ PVOID Context)
|
|
|
|
{
|
|
|
|
PCOUNT_THREAD_DATA ThreadData;
|
|
|
|
PKTHREAD Thread;
|
|
|
|
NTSTATUS Status;
|
|
|
|
LONG PreviousState;
|
|
|
|
ULONG i;
|
|
|
|
volatile ULONG *Counter;
|
|
|
|
KPRIORITY PriorityIncrement;
|
|
|
|
KPRIORITY Priority;
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(Context);
|
|
|
|
|
|
|
|
ThreadData = ExAllocatePoolWithTag(PagedPool, sizeof(*ThreadData), 'CEmK');
|
|
|
|
if (skip(ThreadData != NULL, "Out of memory\n"))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
KeInitializeEvent(&ThreadData->Event, SynchronizationEvent, FALSE);
|
|
|
|
KeInitializeEvent(&ThreadData->WaitEvent, SynchronizationEvent, FALSE);
|
|
|
|
Counter = &ThreadData->Counter;
|
|
|
|
|
|
|
|
for (PriorityIncrement = 0; PriorityIncrement <= 8; PriorityIncrement++)
|
|
|
|
{
|
|
|
|
ThreadData->PriorityIncrement = PriorityIncrement;
|
|
|
|
ThreadData->Counter = 0;
|
|
|
|
RtlFillMemory(ThreadData->CounterValues,
|
|
|
|
sizeof(ThreadData->CounterValues),
|
|
|
|
0xFE);
|
|
|
|
Thread = KmtStartThread(CountThread, ThreadData);
|
|
|
|
Priority = KeQueryPriorityThread(KeGetCurrentThread());
|
|
|
|
ok(Priority == 8, "[%lu] Priority = %lu\n", PriorityIncrement, Priority);
|
|
|
|
for (i = 1; i <= NUM_SCHED_TESTS; i++)
|
|
|
|
{
|
|
|
|
Status = KeWaitForSingleObject(&ThreadData->WaitEvent, Executive, KernelMode, FALSE, NULL);
|
|
|
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
|
|
|
PreviousState = KeSetEvent(&ThreadData->Event, PriorityIncrement, FALSE);
|
|
|
|
*Counter = i;
|
|
|
|
ok_eq_long(PreviousState, 0L);
|
|
|
|
}
|
|
|
|
Priority = KeQueryPriorityThread(KeGetCurrentThread());
|
|
|
|
ok(Priority == 8, "[%lu] Priority = %lu\n", PriorityIncrement, Priority);
|
|
|
|
KmtFinishThread(Thread, NULL);
|
|
|
|
|
|
|
|
if (PriorityIncrement == 0)
|
|
|
|
{
|
|
|
|
/* Both threads have the same priority, so either can win the race */
|
|
|
|
ok(ThreadData->CounterValues[0] == 0 || ThreadData->CounterValues[0] == 1,
|
|
|
|
"[%lu] Counter 0 = %lu\n",
|
|
|
|
PriorityIncrement, ThreadData->CounterValues[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* CountThread has the higher priority, it will always win */
|
|
|
|
ok(ThreadData->CounterValues[0] == 0,
|
|
|
|
"[%lu] Counter 0 = %lu\n",
|
|
|
|
PriorityIncrement, ThreadData->CounterValues[0]);
|
|
|
|
}
|
|
|
|
for (i = 1; i < NUM_SCHED_TESTS; i++)
|
|
|
|
{
|
|
|
|
if (PriorityIncrement == 0)
|
|
|
|
{
|
|
|
|
ok(ThreadData->CounterValues[i] == i ||
|
|
|
|
ThreadData->CounterValues[i] == i + 1,
|
|
|
|
"[%lu] Counter %lu = %lu, expected %lu or %lu\n",
|
|
|
|
PriorityIncrement, i,
|
|
|
|
ThreadData->CounterValues[i], i, i + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(ThreadData->CounterValues[i] == ThreadData->CounterValues[i - 1] + 1,
|
|
|
|
"[%lu] Counter %lu = %lu, expected %lu\n",
|
|
|
|
PriorityIncrement, i,
|
|
|
|
ThreadData->CounterValues[i], ThreadData->CounterValues[i - 1] + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ExFreePoolWithTag(ThreadData, 'CEmK');
|
|
|
|
}
|
|
|
|
|
2011-08-05 21:07:52 +00:00
|
|
|
START_TEST(KeEvent)
|
|
|
|
{
|
2015-09-19 12:57:51 +00:00
|
|
|
PKTHREAD Thread;
|
2011-08-05 21:07:52 +00:00
|
|
|
KEVENT Event;
|
|
|
|
KIRQL Irql;
|
2015-09-19 11:27:18 +00:00
|
|
|
KIRQL Irqls[] = { PASSIVE_LEVEL, APC_LEVEL, DISPATCH_LEVEL };
|
2015-09-19 12:15:16 +00:00
|
|
|
ULONG i;
|
2011-08-10 13:49:36 +00:00
|
|
|
KPRIORITY PriorityIncrement;
|
2011-08-05 21:07:52 +00:00
|
|
|
|
2015-09-19 12:15:16 +00:00
|
|
|
for (i = 0; i < RTL_NUMBER_OF(Irqls); ++i)
|
2011-08-05 21:07:52 +00:00
|
|
|
{
|
|
|
|
KeRaiseIrql(Irqls[i], &Irql);
|
|
|
|
TestEventFunctional(&Event, NotificationEvent, Irqls[i]);
|
|
|
|
TestEventFunctional(&Event, SynchronizationEvent, Irqls[i]);
|
|
|
|
KeLowerIrql(Irql);
|
|
|
|
}
|
|
|
|
|
2015-09-19 12:15:16 +00:00
|
|
|
for (i = 0; i < RTL_NUMBER_OF(Irqls); ++i)
|
2011-08-10 13:49:36 +00:00
|
|
|
{
|
|
|
|
/* creating threads above DISPATCH_LEVEL... nope */
|
2015-09-19 11:27:18 +00:00
|
|
|
if (Irqls[i] >= DISPATCH_LEVEL)
|
2011-08-10 13:49:36 +00:00
|
|
|
continue;
|
|
|
|
KeRaiseIrql(Irqls[i], &Irql);
|
|
|
|
trace("IRQL: %u\n", Irqls[i]);
|
|
|
|
for (PriorityIncrement = -1; PriorityIncrement <= 8; ++PriorityIncrement)
|
|
|
|
{
|
2015-09-19 12:15:16 +00:00
|
|
|
if (PriorityIncrement < 0 && KmtIsCheckedBuild)
|
|
|
|
continue;
|
2011-08-10 13:49:36 +00:00
|
|
|
trace("PriorityIncrement: %ld\n", PriorityIncrement);
|
|
|
|
trace("-> Checking KeSetEvent, NotificationEvent\n");
|
|
|
|
TestEventConcurrent(&Event, NotificationEvent, Irqls[i], KeSetEvent, PriorityIncrement, 1, TRUE);
|
|
|
|
trace("-> Checking KeSetEvent, SynchronizationEvent\n");
|
|
|
|
TestEventConcurrent(&Event, SynchronizationEvent, Irqls[i], KeSetEvent, PriorityIncrement, 0, FALSE);
|
|
|
|
trace("-> Checking KePulseEvent, NotificationEvent\n");
|
|
|
|
TestEventConcurrent(&Event, NotificationEvent, Irqls[i], KePulseEvent, PriorityIncrement, 0, TRUE);
|
|
|
|
trace("-> Checking KePulseEvent, SynchronizationEvent\n");
|
|
|
|
TestEventConcurrent(&Event, SynchronizationEvent, Irqls[i], KePulseEvent, PriorityIncrement, 0, FALSE);
|
|
|
|
}
|
|
|
|
KeLowerIrql(Irql);
|
|
|
|
}
|
2011-08-05 21:12:11 +00:00
|
|
|
|
2011-08-05 21:07:52 +00:00
|
|
|
ok_irql(PASSIVE_LEVEL);
|
|
|
|
KmtSetIrql(PASSIVE_LEVEL);
|
2015-09-19 12:57:51 +00:00
|
|
|
|
|
|
|
Thread = KmtStartThread(TestEventScheduling, NULL);
|
|
|
|
KmtFinishThread(Thread, NULL);
|
2011-08-05 21:07:52 +00:00
|
|
|
}
|