mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Use MmDeleteKernelStack and remove KeReleaseThread
svn path=/trunk/; revision=14696
This commit is contained in:
parent
c683236f8a
commit
05c22b76ae
2 changed files with 74 additions and 37 deletions
|
@ -45,45 +45,82 @@ PsIdleThreadMain(PVOID Context)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/** Initialization of system idle thread
|
||||
*
|
||||
/*
|
||||
* HACK-O-RAMA
|
||||
* Antique vestigial code left alive for the sole purpose of First/Idle Thread
|
||||
* creation until I can merge my fix for properly creating them.
|
||||
*/
|
||||
VOID INIT_FUNCTION
|
||||
NTSTATUS
|
||||
PsInitializeIdleOrFirstThread(PEPROCESS Process,
|
||||
PETHREAD* ThreadPtr,
|
||||
PKSTART_ROUTINE StartRoutine,
|
||||
KPROCESSOR_MODE AccessMode,
|
||||
BOOLEAN First)
|
||||
{
|
||||
PETHREAD Thread;
|
||||
PVOID KernelStack;
|
||||
extern unsigned int init_stack;
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
Thread = ExAllocatePool(NonPagedPool, sizeof(ETHREAD));
|
||||
|
||||
RtlZeroMemory(Thread, sizeof(ETHREAD));
|
||||
Thread->ThreadsProcess = Process;
|
||||
|
||||
DPRINT("Thread = %x\n",Thread);
|
||||
|
||||
if (First)
|
||||
{
|
||||
KernelStack = (PVOID)init_stack;
|
||||
}
|
||||
else
|
||||
{
|
||||
KernelStack = MmCreateKernelStack(FALSE);
|
||||
}
|
||||
|
||||
KeInitializeThread(&Process->Pcb,
|
||||
&Thread->Tcb,
|
||||
PspSystemThreadStartup,
|
||||
StartRoutine,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
KernelStack);
|
||||
Thread->Tcb.ApcQueueable = TRUE;
|
||||
|
||||
InitializeListHead(&Thread->IrpList);
|
||||
|
||||
DPRINT("Thread->Cid.UniqueThread %d\n",Thread->Cid.UniqueThread);
|
||||
|
||||
*ThreadPtr = Thread;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* HACK-O-RAMA
|
||||
* Antique vestigial code left alive for the sole purpose of First/Idle Thread
|
||||
* creation until I can merge my fix for properly creating them.
|
||||
*/
|
||||
VOID
|
||||
INIT_FUNCTION
|
||||
PsInitIdleThread(VOID)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PETHREAD IdleThread;
|
||||
KIRQL oldIrql;
|
||||
PETHREAD IdleThread;
|
||||
KIRQL oldIrql;
|
||||
|
||||
Status = PsInitializeThread(PsIdleProcess,
|
||||
&IdleThread,
|
||||
NULL,
|
||||
KernelMode,
|
||||
FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Couldn't create idle system thread! Status: 0x%x\n", Status);
|
||||
KEBUGCHECK(0);
|
||||
return;
|
||||
}
|
||||
PsInitializeIdleOrFirstThread(PsIdleProcess,
|
||||
&IdleThread,
|
||||
PsIdleThreadMain,
|
||||
KernelMode,
|
||||
FALSE);
|
||||
|
||||
IdleThread->StartAddress = PsIdleThreadMain;
|
||||
Status = KiArchInitThread(&IdleThread->Tcb, PsIdleThreadMain, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Couldn't initialize system idle thread! Status: 0x%x\n", Status);
|
||||
ObDereferenceObject(IdleThread);
|
||||
KEBUGCHECK(0);
|
||||
return;
|
||||
}
|
||||
|
||||
oldIrql = KeAcquireDispatcherDatabaseLock ();
|
||||
KiUnblockThread(&IdleThread->Tcb, NULL, 0);
|
||||
KeReleaseDispatcherDatabaseLock(oldIrql);
|
||||
|
||||
KeGetCurrentPrcb()->IdleThread = &IdleThread->Tcb;
|
||||
KeSetPriorityThread(&IdleThread->Tcb, LOW_PRIORITY);
|
||||
KeSetAffinityThread(&IdleThread->Tcb, 1 << 0);
|
||||
oldIrql = KeAcquireDispatcherDatabaseLock ();
|
||||
KiUnblockThread(&IdleThread->Tcb, NULL, 0);
|
||||
KeReleaseDispatcherDatabaseLock(oldIrql);
|
||||
|
||||
KeGetCurrentPrcb()->IdleThread = &IdleThread->Tcb;
|
||||
KeSetPriorityThread(&IdleThread->Tcb, LOW_PRIORITY);
|
||||
KeSetAffinityThread(&IdleThread->Tcb, 1 << 0);
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ PsInitThreadManagment(VOID)
|
|||
|
||||
ObpCreateTypeObject(PsThreadType);
|
||||
|
||||
PsInitializeThread(NULL, &FirstThread, NULL, KernelMode, TRUE);
|
||||
PsInitializeIdleOrFirstThread(PsInitialSystemProcess, &FirstThread, NULL, KernelMode, TRUE);
|
||||
FirstThread->Tcb.State = Running;
|
||||
FirstThread->Tcb.FreezeCount = 0;
|
||||
FirstThread->Tcb.UserAffinity = (1 << 0); /* Set the affinity of the first thread to the boot processor */
|
||||
|
|
Loading…
Reference in a new issue