Implemented NtSignalAndWaitForSingleObject()

svn path=/trunk/; revision=1491
This commit is contained in:
Eric Kohl 2001-01-02 00:47:08 +00:00
parent 240c9da1da
commit 58f7f41275
2 changed files with 112 additions and 40 deletions

View file

@ -1,5 +1,5 @@
/* $Id: zw.h,v 1.39 2000/12/23 02:37:36 dwelch Exp $ /* $Id: zw.h,v 1.40 2001/01/02 00:46:10 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -4844,31 +4844,30 @@ ZwUnmapViewOfSection(
/* --- OBJECT SYNCHRONIZATION --- */ /* --- OBJECT SYNCHRONIZATION --- */
/* /*
* FUNCTION: Signals an event and wait for it to be signaled again. * FUNCTION: Signals an object and wait for an other one.
* ARGUMENTS: * ARGUMENTS:
* EventHandle = Handle to the event that should be signaled * SignalObject = Handle to the object that should be signaled
* WaitObject = Handle to the object that should be waited for
* Alertable = True if the wait is alertable * Alertable = True if the wait is alertable
* Time = The time to wait * Time = The time to wait
* NumberOfWaitingThreads = Number of waiting threads
* RETURNS: Status * RETURNS: Status
*/ */
NTSTATUS NTSTATUS
STDCALL STDCALL
NtSignalAndWaitForSingleObject( NtSignalAndWaitForSingleObject(
IN HANDLE EventHandle, IN HANDLE SignalObject,
IN HANDLE WaitObject,
IN BOOLEAN Alertable, IN BOOLEAN Alertable,
IN PLARGE_INTEGER Time, IN PLARGE_INTEGER Time
PULONG NumberOfWaitingThreads OPTIONAL
); );
NTSTATUS NTSTATUS
STDCALL STDCALL
ZwSignalAndWaitForSingleObject( NtSignalAndWaitForSingleObject(
IN HANDLE EventHandle, IN HANDLE SignalObject,
IN HANDLE WaitObject,
IN BOOLEAN Alertable, IN BOOLEAN Alertable,
IN PLARGE_INTEGER Time, IN PLARGE_INTEGER Time
PULONG NumberOfWaitingThreads OPTIONAL
); );
/* /*
@ -4902,6 +4901,7 @@ ZwWaitForMultipleObjects (
IN BOOLEAN Alertable, IN BOOLEAN Alertable,
IN PLARGE_INTEGER Time IN PLARGE_INTEGER Time
); );
/* /*
* FUNCTION: Waits for an object to become signalled. * FUNCTION: Waits for an object to become signalled.
* ARGUMENTS: * ARGUMENTS:
@ -4949,7 +4949,12 @@ ZwWaitHighEventPair(
IN HANDLE EventPairHandle IN HANDLE EventPairHandle
); );
/*
* FUNCTION: Waits for the low part of an eventpair to become signalled
* ARGUMENTS:
* EventPairHandle = Handle to the event pair.
* RETURNS: Status
*/
NTSTATUS NTSTATUS
STDCALL STDCALL
NtWaitLowEventPair( NtWaitLowEventPair(

View file

@ -677,11 +677,78 @@ NTSTATUS STDCALL NtWaitForSingleObject (IN HANDLE Object,
} }
NTSTATUS STDCALL NtSignalAndWaitForSingleObject (IN HANDLE EventHandle, NTSTATUS STDCALL
NtSignalAndWaitForSingleObject(IN HANDLE SignalObject,
IN HANDLE WaitObject,
IN BOOLEAN Alertable, IN BOOLEAN Alertable,
IN PLARGE_INTEGER Time, IN PLARGE_INTEGER Time)
PULONG
NumberOfWaitingThreads OPTIONAL)
{ {
UNIMPLEMENTED; KPROCESSOR_MODE ProcessorMode;
DISPATCHER_HEADER* hdr;
PVOID SignalObj;
PVOID WaitObj;
NTSTATUS Status;
ProcessorMode = CURRENT_KPCR->CurrentThread->PreviousMode;
Status = ObReferenceObjectByHandle(SignalObject,
0,
NULL,
ProcessorMode,
&SignalObj,
NULL);
if (!NT_SUCCESS(Status))
{
return Status;
}
Status = ObReferenceObjectByHandle(WaitObject,
SYNCHRONIZE,
NULL,
ProcessorMode,
&WaitObj,
NULL);
if (!NT_SUCCESS(Status))
{
ObDereferenceObject(SignalObj);
return Status;
}
hdr = (DISPATCHER_HEADER *)SignalObj;
switch (hdr->Type)
{
case InternalNotificationEvent:
case InternalSynchronizationEvent:
KeSetEvent(SignalObj,
EVENT_INCREMENT,
TRUE);
break;
case InternalMutexType:
KeReleaseMutex(SignalObj,
TRUE);
break;
case InternalSemaphoreType:
KeReleaseSemaphore(SignalObj,
SEMAPHORE_INCREMENT,
1,
TRUE);
break;
default:
ObDereferenceObject(SignalObj);
ObDereferenceObject(WaitObj);
return STATUS_OBJECT_TYPE_MISMATCH;
}
Status = KeWaitForSingleObject(WaitObj,
UserRequest,
ProcessorMode,
Alertable,
Time);
ObDereferenceObject(SignalObj);
ObDereferenceObject(WaitObj);
return Status;
} }