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,44 +4844,43 @@ 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
* Alertable = True if the wait is alertable * WaitObject = Handle to the object that should be waited for
* 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 BOOLEAN Alertable, IN HANDLE WaitObject,
IN PLARGE_INTEGER Time, IN BOOLEAN Alertable,
PULONG NumberOfWaitingThreads OPTIONAL IN PLARGE_INTEGER Time
); );
NTSTATUS NTSTATUS
STDCALL STDCALL
ZwSignalAndWaitForSingleObject( NtSignalAndWaitForSingleObject(
IN HANDLE EventHandle, IN HANDLE SignalObject,
IN BOOLEAN Alertable, IN HANDLE WaitObject,
IN PLARGE_INTEGER Time, IN BOOLEAN Alertable,
PULONG NumberOfWaitingThreads OPTIONAL IN PLARGE_INTEGER Time
); );
/* /*
* FUNCTION: Waits for multiple objects to become signalled. * FUNCTION: Waits for multiple objects to become signalled.
* ARGUMENTS: * ARGUMENTS:
* Count = The number of objects * Count = The number of objects
* Object = The array of object handles * Object = The array of object handles
* WaitType = Can be one of the values UserMode or KernelMode * WaitType = Can be one of the values UserMode or KernelMode
* Alertable = If true the wait is alertable. * Alertable = If true the wait is alertable.
* Time = The maximum wait time. * Time = The maximum wait time.
* REMARKS: * REMARKS:
* This function maps to the win32 WaitForMultipleObjectEx. * This function maps to the win32 WaitForMultipleObjectEx.
* RETURNS: Status * RETURNS: Status
*/ */
NTSTATUS NTSTATUS
STDCALL STDCALL
@ -4890,7 +4889,7 @@ NtWaitForMultipleObjects (
IN HANDLE Object[], IN HANDLE Object[],
IN CINT WaitType, IN CINT WaitType,
IN BOOLEAN Alertable, IN BOOLEAN Alertable,
IN PLARGE_INTEGER Time IN PLARGE_INTEGER Time
); );
NTSTATUS NTSTATUS
@ -4900,24 +4899,25 @@ ZwWaitForMultipleObjects (
IN HANDLE Object[], IN HANDLE Object[],
IN CINT WaitType, IN CINT WaitType,
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:
* Object = The object handle * Object = The object handle
* Alertable = If true the wait is alertable. * Alertable = If true the wait is alertable.
* Time = The maximum wait time. * Time = The maximum wait time.
* REMARKS: * REMARKS:
* This function maps to the win32 WaitForSingleObjectEx. * This function maps to the win32 WaitForSingleObjectEx.
* RETURNS: Status * RETURNS: Status
*/ */
NTSTATUS NTSTATUS
STDCALL STDCALL
NtWaitForSingleObject ( NtWaitForSingleObject (
IN HANDLE Object, IN HANDLE Object,
IN BOOLEAN Alertable, IN BOOLEAN Alertable,
IN PLARGE_INTEGER Time IN PLARGE_INTEGER Time
); );
NTSTATUS NTSTATUS
@ -4925,16 +4925,16 @@ STDCALL
ZwWaitForSingleObject ( ZwWaitForSingleObject (
IN HANDLE Object, IN HANDLE Object,
IN BOOLEAN Alertable, IN BOOLEAN Alertable,
IN PLARGE_INTEGER Time IN PLARGE_INTEGER Time
); );
/* --- EVENT PAIR OBJECT --- */ /* --- EVENT PAIR OBJECT --- */
/* /*
* FUNCTION: Waits for the high part of an eventpair to become signalled * FUNCTION: Waits for the high part of an eventpair to become signalled
* ARGUMENTS: * ARGUMENTS:
* EventPairHandle = Handle to the event pair. * EventPairHandle = Handle to the event pair.
* RETURNS: Status * RETURNS: Status
*/ */
NTSTATUS NTSTATUS
@ -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
IN BOOLEAN Alertable, NtSignalAndWaitForSingleObject(IN HANDLE SignalObject,
IN PLARGE_INTEGER Time, IN HANDLE WaitObject,
PULONG IN BOOLEAN Alertable,
NumberOfWaitingThreads OPTIONAL) IN PLARGE_INTEGER Time)
{ {
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;
} }