mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
Implemented the ability to create suspended threads.
svn path=/trunk/; revision=3206
This commit is contained in:
parent
cae7cd6a6c
commit
aaf641d620
2 changed files with 168 additions and 141 deletions
|
@ -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
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -614,8 +614,27 @@ NtCreateThread (PHANDLE ThreadHandle,
|
||||||
}
|
}
|
||||||
else
|
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);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* 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
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/ps/suspend.c
|
* FILE: ntoskrnl/ps/suspend.c
|
||||||
|
@ -46,6 +46,7 @@ PiSuspendThreadRundownRoutine(PKAPC Apc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
PiSuspendThreadKernelRoutine(PKAPC Apc,
|
PiSuspendThreadKernelRoutine(PKAPC Apc,
|
||||||
PKNORMAL_ROUTINE* NormalRoutine,
|
PKNORMAL_ROUTINE* NormalRoutine,
|
||||||
|
@ -55,6 +56,7 @@ PiSuspendThreadKernelRoutine(PKAPC Apc,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
PiSuspendThreadNormalRoutine(PVOID NormalContext,
|
PiSuspendThreadNormalRoutine(PVOID NormalContext,
|
||||||
PVOID SystemArgument1,
|
PVOID SystemArgument1,
|
||||||
|
@ -67,13 +69,17 @@ PiSuspendThreadNormalRoutine(PVOID NormalContext,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
PsResumeThread(PETHREAD Thread, PULONG SuspendCount)
|
PsResumeThread(PETHREAD Thread, PULONG SuspendCount)
|
||||||
{
|
{
|
||||||
|
*SuspendCount = InterlockedDecrement((PULONG)&Thread->Tcb.SuspendCount);
|
||||||
KeReleaseSemaphore(&Thread->Tcb.SuspendSemaphore, IO_NO_INCREMENT, 1, FALSE);
|
KeReleaseSemaphore(&Thread->Tcb.SuspendSemaphore, IO_NO_INCREMENT, 1, FALSE);
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
PsSuspendThread(PETHREAD Thread, PULONG PreviousSuspendCount)
|
PsSuspendThread(PETHREAD Thread, PULONG PreviousSuspendCount)
|
||||||
{
|
{
|
||||||
|
@ -91,9 +97,11 @@ PsSuspendThread(PETHREAD Thread, PULONG PreviousSuspendCount)
|
||||||
{
|
{
|
||||||
InterlockedDecrement(&Thread->Tcb.SuspendSemaphore.Header.SignalState);
|
InterlockedDecrement(&Thread->Tcb.SuspendSemaphore.Header.SignalState);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
NtResumeThread(IN HANDLE ThreadHandle,
|
NtResumeThread(IN HANDLE ThreadHandle,
|
||||||
IN PULONG SuspendCount)
|
IN PULONG SuspendCount)
|
||||||
|
@ -109,6 +117,9 @@ NtResumeThread (IN HANDLE ThreadHandle,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG Count;
|
ULONG Count;
|
||||||
|
|
||||||
|
DPRINT("NtResumeThead(ThreadHandle %lx SuspendCount %p)\n",
|
||||||
|
ThreadHandle, SuspendCount);
|
||||||
|
|
||||||
Status = ObReferenceObjectByHandle(ThreadHandle,
|
Status = ObReferenceObjectByHandle(ThreadHandle,
|
||||||
THREAD_SUSPEND_RESUME,
|
THREAD_SUSPEND_RESUME,
|
||||||
PsThreadType,
|
PsThreadType,
|
||||||
|
@ -128,7 +139,7 @@ NtResumeThread (IN HANDLE ThreadHandle,
|
||||||
|
|
||||||
ObDereferenceObject((PVOID)Thread);
|
ObDereferenceObject((PVOID)Thread);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,10 +183,7 @@ NtSuspendThread (IN HANDLE ThreadHandle,
|
||||||
|
|
||||||
ObDereferenceObject((PVOID)Thread);
|
ObDereferenceObject((PVOID)Thread);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue