Implemented the ability to create suspended threads.

svn path=/trunk/; revision=3206
This commit is contained in:
Eric Kohl 2002-07-10 15:17:35 +00:00
parent cae7cd6a6c
commit aaf641d620
2 changed files with 168 additions and 141 deletions

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.46 2002/03/05 00:20:54 ekohl Exp $
/* $Id: create.c,v 1.47 2002/07/10 15:17:34 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -614,8 +614,27 @@ NtCreateThread (PHANDLE ThreadHandle,
}
else
{
KeBugCheck(0);
DPRINT("Creating suspended\n");
/*
* Simulate a call to NtWaitForSingleObject() upon thread startup
*/
/* Increment the suspend counter */
Thread->Tcb.SuspendCount++;
/* Add one wait-block for suspend semaphore */
Thread->Tcb.WaitStatus = STATUS_UNSUCCESSFUL;
Thread->Tcb.WaitBlockList = &Thread->Tcb.WaitBlock[0];
Thread->Tcb.WaitBlock[0].Object = (POBJECT)&Thread->Tcb.SuspendSemaphore;
Thread->Tcb.WaitBlock[0].Thread = &Thread->Tcb;
Thread->Tcb.WaitBlock[0].WaitKey = STATUS_WAIT_0;
Thread->Tcb.WaitBlock[0].WaitType = WaitAny;
Thread->Tcb.WaitBlock[0].NextWaitBlock = NULL;
InsertTailList(&Thread->Tcb.SuspendSemaphore.Header.WaitListHead,
&Thread->Tcb.WaitBlock[0].WaitListEntry);
}
return(STATUS_SUCCESS);
}

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: suspend.c,v 1.6 2001/08/27 01:22:22 ekohl Exp $
/* $Id: suspend.c,v 1.7 2002/07/10 15:17:35 ekohl Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ps/suspend.c
@ -46,6 +46,7 @@ PiSuspendThreadRundownRoutine(PKAPC Apc)
{
}
VOID STDCALL
PiSuspendThreadKernelRoutine(PKAPC Apc,
PKNORMAL_ROUTINE* NormalRoutine,
@ -55,6 +56,7 @@ PiSuspendThreadKernelRoutine(PKAPC Apc,
{
}
VOID STDCALL
PiSuspendThreadNormalRoutine(PVOID NormalContext,
PVOID SystemArgument1,
@ -67,13 +69,17 @@ PiSuspendThreadNormalRoutine(PVOID NormalContext,
NULL);
}
NTSTATUS
PsResumeThread(PETHREAD Thread, PULONG SuspendCount)
{
*SuspendCount = InterlockedDecrement((PULONG)&Thread->Tcb.SuspendCount);
KeReleaseSemaphore(&Thread->Tcb.SuspendSemaphore, IO_NO_INCREMENT, 1, FALSE);
return(STATUS_SUCCESS);
}
NTSTATUS
PsSuspendThread(PETHREAD Thread, PULONG PreviousSuspendCount)
{
@ -91,9 +97,11 @@ PsSuspendThread(PETHREAD Thread, PULONG PreviousSuspendCount)
{
InterlockedDecrement(&Thread->Tcb.SuspendSemaphore.Header.SignalState);
}
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL
NtResumeThread(IN HANDLE ThreadHandle,
IN PULONG SuspendCount)
@ -109,6 +117,9 @@ NtResumeThread (IN HANDLE ThreadHandle,
NTSTATUS Status;
ULONG Count;
DPRINT("NtResumeThead(ThreadHandle %lx SuspendCount %p)\n",
ThreadHandle, SuspendCount);
Status = ObReferenceObjectByHandle(ThreadHandle,
THREAD_SUSPEND_RESUME,
PsThreadType,
@ -128,7 +139,7 @@ NtResumeThread (IN HANDLE ThreadHandle,
ObDereferenceObject((PVOID)Thread);
return STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
@ -172,10 +183,7 @@ NtSuspendThread (IN HANDLE ThreadHandle,
ObDereferenceObject((PVOID)Thread);
return STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
/* EOF */