From e4981e3a090a173353f30fb05fbbd155be102dcf Mon Sep 17 00:00:00 2001 From: jean Date: Thu, 25 Mar 1999 13:53:45 +0000 Subject: [PATCH] work on semaphores. svn path=/trunk/; revision=341 --- reactos/ntoskrnl/ke/wait.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/reactos/ntoskrnl/ke/wait.c b/reactos/ntoskrnl/ke/wait.c index a68b24fb011..1a2a22eccad 100644 --- a/reactos/ntoskrnl/ke/wait.c +++ b/reactos/ntoskrnl/ke/wait.c @@ -101,6 +101,8 @@ BOOLEAN KeDispatcherObjectWakeOne(DISPATCHER_HEADER* hdr) WaitListEntry); DPRINT("current_entry %x current %x\n",current_entry,current); DPRINT("Waking %x\n",current->Thread); + if (hdr->Type == SemaphoreType) + hdr->SignalState--; PsResumeThread(CONTAINING_RECORD(current->Thread,ETHREAD,Tcb)); return(TRUE); } @@ -148,15 +150,19 @@ NTSTATUS KeWaitForSingleObject(PVOID Object, KWAIT_BLOCK blk; DPRINT("Entering KeWaitForSingleObject(Object %x)\n",Object); + // FIXME : if KeReleaseSemaphore called with wait just before KeWaitxxx + // we must do something special. KeAcquireDispatcherDatabaseLock(FALSE); - if (hdr->SignalState) + if (hdr->SignalState > 0) { if (hdr->Type == SynchronizationEvent) - { - hdr->SignalState=FALSE; - } + { + hdr->SignalState=FALSE; + } + else if (hdr->Type == SemaphoreType) + hdr->SignalState--; KeReleaseDispatcherDatabaseLock(FALSE); return(STATUS_SUCCESS); }