diff --git a/reactos/ntoskrnl/ex/power.c b/reactos/ntoskrnl/ex/power.c index f4f028936b8..94b3159cfa8 100644 --- a/reactos/ntoskrnl/ex/power.c +++ b/reactos/ntoskrnl/ex/power.c @@ -52,6 +52,11 @@ NtShutdownSystem(IN SHUTDOWN_ACTION Action) HalReturnToFirmware (FIRMWARE_OFF); #else PopSetSystemPowerState(PowerSystemShutdown); + __asm__("cli\n"); + while (TRUE) + { + ; + } #endif } else if (Action == ShutdownReboot) diff --git a/reactos/ntoskrnl/lpc/reply.c b/reactos/ntoskrnl/lpc/reply.c index e7a1698e84b..2f6ff37a9d7 100644 --- a/reactos/ntoskrnl/lpc/reply.c +++ b/reactos/ntoskrnl/lpc/reply.c @@ -1,4 +1,4 @@ -/* $Id: reply.c,v 1.13 2003/04/26 23:13:32 hyperion Exp $ +/* $Id: reply.c,v 1.14 2003/05/01 22:00:31 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -220,7 +220,10 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle, if (!NT_SUCCESS(Status)) { - DPRINT1("NtReplyWaitReceivePortEx() = %x\n", Status); + if (STATUS_THREAD_IS_TERMINATING != Status) + { + DPRINT1("NtReplyWaitReceivePortEx() = %x\n", Status); + } ObDereferenceObject(Port); return(Status); } diff --git a/reactos/ntoskrnl/ps/kill.c b/reactos/ntoskrnl/ps/kill.c index 225d47304ac..0d5c8e696a5 100644 --- a/reactos/ntoskrnl/ps/kill.c +++ b/reactos/ntoskrnl/ps/kill.c @@ -1,4 +1,4 @@ -/* $Id: kill.c,v 1.58 2002/11/27 20:54:37 hbirr Exp $ +/* $Id: kill.c,v 1.59 2003/05/01 22:00:31 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -159,7 +159,7 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus) PKMUTANT Mutant; CurrentThread = PsGetCurrentThread(); - + DPRINT("terminating %x\n",CurrentThread); KeAcquireSpinLock(&PiThreadListLock, &oldIrql); @@ -188,6 +188,7 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus) KeAcquireSpinLock(&PiThreadListLock, &oldIrql); PsDispatchThreadNoLock(THREAD_STATE_TERMINATED_1); +DPRINT1("Unexpected return, CurrentThread %x PsGetCurrentThread() %x\n", CurrentThread, PsGetCurrentThread()); KeBugCheck(0); } @@ -224,6 +225,7 @@ PsTerminateOtherThread(PETHREAD Thread, */ { PKAPC Apc; + NTSTATUS Status; DPRINT("PsTerminateOtherThread(Thread %x, ExitStatus %x)\n", Thread, ExitStatus); @@ -243,6 +245,12 @@ PsTerminateOtherThread(PETHREAD Thread, NULL, NULL, KernelMode); + if (THREAD_STATE_BLOCKED == Thread->Tcb.State && UserMode == Thread->Tcb.WaitMode) + { + DPRINT("Unblocking thread\n"); + Status = STATUS_THREAD_IS_TERMINATING; + PsUnblockThread(Thread, &Status); + } } NTSTATUS STDCALL diff --git a/reactos/ntoskrnl/ps/thread.c b/reactos/ntoskrnl/ps/thread.c index 86981bf5a18..ea7e670aa41 100644 --- a/reactos/ntoskrnl/ps/thread.c +++ b/reactos/ntoskrnl/ps/thread.c @@ -1,4 +1,4 @@ -/* $Id: thread.c,v 1.110 2003/04/28 14:32:36 fireball Exp $ +/* $Id: thread.c,v 1.111 2003/05/01 22:00:31 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -71,9 +71,10 @@ HANDLE STDCALL PsGetCurrentThreadId(VOID) return(PsGetCurrentThread()->Cid.UniqueThread); } -VOID +static VOID PsInsertIntoThreadList(KPRIORITY Priority, PETHREAD Thread) { + assert(THREAD_STATE_READY == Thread->Tcb.State); if (Priority >= MAXIMUM_PRIORITY || Priority < 0) { DPRINT1("Invalid thread priority\n"); @@ -269,12 +270,19 @@ PsUnblockThread(PETHREAD Thread, PNTSTATUS WaitStatus) KIRQL oldIrql; KeAcquireSpinLock(&PiThreadListLock, &oldIrql); - if (WaitStatus != NULL) + if (THREAD_STATE_TERMINATED_1 != Thread->Tcb.State) { - Thread->Tcb.WaitStatus = *WaitStatus; + if (WaitStatus != NULL) + { + Thread->Tcb.WaitStatus = *WaitStatus; + } + Thread->Tcb.State = THREAD_STATE_READY; + PsInsertIntoThreadList(Thread->Tcb.Priority, Thread); + } + else + { + DPRINT("Can't unblock thread 0x%08x because it's terminating\n", Thread); } - Thread->Tcb.State = THREAD_STATE_READY; - PsInsertIntoThreadList(Thread->Tcb.Priority, Thread); KeReleaseSpinLock(&PiThreadListLock, oldIrql); }