-/* $Id: create.c,v 1.24 2000/10/22 16:36:53 ekohl Exp $
+/* $Id: create.c,v 1.25 2000/12/22 13:37:41 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
{
Teb.Peb = Thread->ThreadsProcess->Peb; /* No PEB yet!! */
}
-// DPRINT1("Teb.Peb %x\n", Teb.Peb);
+ DPRINT("Teb.Peb %x\n", Teb.Peb);
/* store stack information from InitialTeb */
if (InitialTeb != NULL)
*TebPtr = (PNT_TEB)TebBase;
}
-// DPRINT1 ("TEB allocated at %p\n", TebBase);
+ DPRINT("TEB allocated at %p\n", TebBase);
return Status;
}
-NTSTATUS STDCALL NtCreateThread (PHANDLE ThreadHandle,
+NTSTATUS STDCALL NtCreateThread (PHANDLE ThreadHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
HANDLE ProcessHandle,
if (!CreateSuspended)
{
- DPRINT("Not creating suspended\n");
- PsUnfreezeThread(Thread, NULL);
+ DPRINT("Not creating suspended\n");
+ PsResumeThread(Thread);
}
DPRINT("Thread %x\n", Thread);
DPRINT("ObGetReferenceCount(Thread) %d ObGetHandleCount(Thread) %x\n",
*ClientId=Thread->Cid;
}
- PsUnfreezeThread(Thread, NULL);
+ PsResumeThread(Thread);
return(STATUS_SUCCESS);
}
+/* EOF */
-/* $Id: thread.c,v 1.60 2000/12/10 23:42:01 dwelch Exp $
+/* $Id: thread.c,v 1.61 2000/12/22 13:37:41 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
return(r);
}
+ULONG PsResumeThread(PETHREAD Thread)
+{
+ KIRQL oldIrql;
+ ULONG SuspendCount;
+
+ KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
+
+ if (Thread->Tcb.SuspendCount > 0)
+ {
+ Thread->Tcb.SuspendCount--;
+ SuspendCount = Thread->Tcb.SuspendCount;
+ Thread->Tcb.State = THREAD_STATE_RUNNABLE;
+ PsInsertIntoThreadList(Thread->Tcb.Priority, Thread);
+ }
+
+ KeReleaseSpinLock(&PiThreadListLock, oldIrql);
+
+ return SuspendCount;
+}
+
+ULONG PsSuspendThread(PETHREAD Thread)
+{
+ KIRQL oldIrql;
+ ULONG PreviousSuspendCount;
+
+ KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
+
+ PreviousSuspendCount = Thread->Tcb.SuspendCount;
+ if (Thread->Tcb.SuspendCount < MAXIMUM_SUSPEND_COUNT)
+ {
+ Thread->Tcb.SuspendCount++;
+ }
+
+ if (PsGetCurrentThread() == Thread)
+ {
+ DbgPrint("Cannot suspend self\n");
+ KeBugCheck(0);
+ }
+
+ Thread->Tcb.State = THREAD_STATE_SUSPENDED;
+
+ KeReleaseSpinLock(&PiThreadListLock, oldIrql);
+
+ return PreviousSuspendCount;
+}
+
VOID PsInitThreadManagment(VOID)
/*
* FUNCTION: Initialize thread managment
(VOID)PsUnfreezeThread(Thread, &ThreadStatus);
ObDereferenceObject(Thread);
- return(STATUS_SUCCESS);
+ return(STATUS_SUCCESS);
}
NTSTATUS STDCALL NtOpenThread(OUT PHANDLE ThreadHandle,
* ThreadHandle = Handle to the thread that should be resumed
* ResumeCount = The resulting resume count.
* REMARK:
- * A thread is resumed if its suspend count is 0. This procedure maps to
- * the win32 ResumeThread function. ( documentation about the the suspend count can be found here aswell )
+ * A thread is resumed if its suspend count is 0. This procedure maps to
+ * the win32 ResumeThread function. ( documentation about the the suspend
+ * count can be found here aswell )
* RETURNS: Status
*/
{
- UNIMPLEMENTED;
- return(STATUS_UNSUCCESSFUL);
+ PETHREAD Thread;
+ NTSTATUS Status;
+ ULONG Count;
+
+ Status = ObReferenceObjectByHandle(ThreadHandle,
+ THREAD_SUSPEND_RESUME,
+ PsThreadType,
+ UserMode,
+ (PVOID*)&Thread,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+
+ Count = PsResumeThread(Thread);
+ if (SuspendCount != NULL)
+ {
+ *SuspendCount = Count;
+ }
+
+ ObDereferenceObject((PVOID)Thread);
+
+ return STATUS_SUCCESS;
}
* ThreadHandle = Handle to the thread that should be resumed
* PreviousSuspendCount = The resulting/previous suspend count.
* REMARK:
- * A thread will be suspended if its suspend count is greater than 0.
+ * A thread will be suspended if its suspend count is greater than 0.
* This procedure maps to the win32 SuspendThread function. (
* documentation about the the suspend count can be found here aswell )
* The suspend count is not increased if it is greater than
* RETURNS: Status
*/
{
- UNIMPLEMENTED;
- return(STATUS_UNSUCCESSFUL);
+ PETHREAD Thread;
+ NTSTATUS Status;
+ ULONG Count;
+
+ Status = ObReferenceObjectByHandle(ThreadHandle,
+ THREAD_SUSPEND_RESUME,
+ PsThreadType,
+ UserMode,
+ (PVOID*)&Thread,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+
+ Count = PsSuspendThread(Thread);
+ if (PreviousSuspendCount != NULL)
+ {
+ *PreviousSuspendCount = Count;
+ }
+
+ ObDereferenceObject((PVOID)Thread);
+
+ return STATUS_SUCCESS;
}
{
DbgPrint("NtContinue called but TrapFrame was NULL\n");
KeBugCheck(0);
- }
+ }
KeContextToTrapFrame(Context, TrapFrame);
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL NtYieldExecution(VOID)
-{
+{
PsDispatchThread(THREAD_STATE_RUNNABLE);
return(STATUS_SUCCESS);
}