forked from xt-sys/exectos
Allow to postpone thread startup
This commit is contained in:
parent
67496bef28
commit
1d9a79736a
@ -40,7 +40,8 @@ KeInitializeThread(IN PKPROCESS Process,
|
|||||||
IN PVOID StartContext,
|
IN PVOID StartContext,
|
||||||
IN PCONTEXT Context,
|
IN PCONTEXT Context,
|
||||||
IN PVOID EnvironmentBlock,
|
IN PVOID EnvironmentBlock,
|
||||||
IN PVOID Stack);
|
IN PVOID Stack,
|
||||||
|
IN BOOLEAN StartThread);
|
||||||
|
|
||||||
XTAPI
|
XTAPI
|
||||||
VOID
|
VOID
|
||||||
|
@ -22,12 +22,16 @@ KepInitializeKernel(VOID)
|
|||||||
{
|
{
|
||||||
PKPROCESSOR_CONTROL_BLOCK Prcb;
|
PKPROCESSOR_CONTROL_BLOCK Prcb;
|
||||||
ULONG_PTR PageDirectory[2];
|
ULONG_PTR PageDirectory[2];
|
||||||
|
PKPROCESS CurrentProcess;
|
||||||
PKTHREAD CurrentThread;
|
PKTHREAD CurrentThread;
|
||||||
|
|
||||||
/* Get processor control block and current thread */
|
/* Get processor control block and current thread */
|
||||||
Prcb = KeGetCurrentProcessorControlBlock();
|
Prcb = KeGetCurrentProcessorControlBlock();
|
||||||
CurrentThread = KeGetCurrentThread();
|
CurrentThread = KeGetCurrentThread();
|
||||||
|
|
||||||
|
/* Get current process */
|
||||||
|
CurrentProcess = CurrentThread->ApcState.Process;
|
||||||
|
|
||||||
/* Initialize CPU power state structures */
|
/* Initialize CPU power state structures */
|
||||||
PoInitializeProcessorControlBlock(Prcb);
|
PoInitializeProcessorControlBlock(Prcb);
|
||||||
|
|
||||||
@ -35,17 +39,17 @@ KepInitializeKernel(VOID)
|
|||||||
RtlInitializeListHead(&KepProcessListHead);
|
RtlInitializeListHead(&KepProcessListHead);
|
||||||
PageDirectory[0] = 0;
|
PageDirectory[0] = 0;
|
||||||
PageDirectory[1] = 0;
|
PageDirectory[1] = 0;
|
||||||
KeInitializeProcess(CurrentThread->ApcState.Process, 0, 0xFFFFFFFF, PageDirectory, FALSE);
|
KeInitializeProcess(CurrentProcess, 0, 0xFFFFFFFF, PageDirectory, FALSE);
|
||||||
CurrentThread->ApcState.Process->Quantum = MAXCHAR;
|
CurrentProcess->Quantum = MAXCHAR;
|
||||||
|
|
||||||
/* Initialize Idle thread */
|
/* Initialize Idle thread */
|
||||||
KeInitializeThread(CurrentThread->ApcState.Process, CurrentThread, NULL, NULL, NULL, NULL, NULL, Prcb->DpcStack);
|
KeInitializeThread(CurrentProcess, CurrentThread, NULL, NULL, NULL, NULL, NULL, Prcb->DpcStack, TRUE);
|
||||||
CurrentThread->NextProcessor = Prcb->Number;
|
CurrentThread->NextProcessor = Prcb->Number;
|
||||||
CurrentThread->Priority = THREAD_HIGH_PRIORITY;
|
CurrentThread->Priority = THREAD_HIGH_PRIORITY;
|
||||||
CurrentThread->State = Running;
|
CurrentThread->State = Running;
|
||||||
CurrentThread->Affinity = (ULONG_PTR)1 << Prcb->Number;
|
CurrentThread->Affinity = (ULONG_PTR)1 << Prcb->Number;
|
||||||
CurrentThread->WaitIrql = DISPATCH_LEVEL;
|
CurrentThread->WaitIrql = DISPATCH_LEVEL;
|
||||||
CurrentThread->ApcState.Process->ActiveProcessors |= (ULONG_PTR)1 << Prcb->Number;
|
CurrentProcess->ActiveProcessors |= (ULONG_PTR)1 << Prcb->Number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,12 +22,16 @@ KepInitializeKernel(VOID)
|
|||||||
{
|
{
|
||||||
PKPROCESSOR_CONTROL_BLOCK Prcb;
|
PKPROCESSOR_CONTROL_BLOCK Prcb;
|
||||||
ULONG_PTR PageDirectory[2];
|
ULONG_PTR PageDirectory[2];
|
||||||
|
PKPROCESS CurrentProcess;
|
||||||
PKTHREAD CurrentThread;
|
PKTHREAD CurrentThread;
|
||||||
|
|
||||||
/* Get processor control block and current thread */
|
/* Get processor control block and current thread */
|
||||||
Prcb = KeGetCurrentProcessorControlBlock();
|
Prcb = KeGetCurrentProcessorControlBlock();
|
||||||
CurrentThread = KeGetCurrentThread();
|
CurrentThread = KeGetCurrentThread();
|
||||||
|
|
||||||
|
/* Get current process */
|
||||||
|
CurrentProcess = CurrentThread->ApcState.Process;
|
||||||
|
|
||||||
/* Initialize CPU power state structures */
|
/* Initialize CPU power state structures */
|
||||||
PoInitializeProcessorControlBlock(Prcb);
|
PoInitializeProcessorControlBlock(Prcb);
|
||||||
|
|
||||||
@ -35,17 +39,17 @@ KepInitializeKernel(VOID)
|
|||||||
RtlInitializeListHead(&KepProcessListHead);
|
RtlInitializeListHead(&KepProcessListHead);
|
||||||
PageDirectory[0] = 0;
|
PageDirectory[0] = 0;
|
||||||
PageDirectory[1] = 0;
|
PageDirectory[1] = 0;
|
||||||
KeInitializeProcess(CurrentThread->ApcState.Process, 0, 0xFFFFFFFF, PageDirectory, FALSE);
|
KeInitializeProcess(CurrentProcess, 0, 0xFFFFFFFF, PageDirectory, FALSE);
|
||||||
CurrentThread->ApcState.Process->Quantum = MAXCHAR;
|
CurrentProcess->Quantum = MAXCHAR;
|
||||||
|
|
||||||
/* Initialize Idle thread */
|
/* Initialize Idle thread */
|
||||||
KeInitializeThread(CurrentThread->ApcState.Process, CurrentThread, NULL, NULL, NULL, NULL, NULL, Prcb->DpcStack);
|
KeInitializeThread(CurrentProcess, CurrentThread, NULL, NULL, NULL, NULL, NULL, Prcb->DpcStack, TRUE);
|
||||||
CurrentThread->NextProcessor = Prcb->Number;
|
CurrentThread->NextProcessor = Prcb->Number;
|
||||||
CurrentThread->Priority = THREAD_HIGH_PRIORITY;
|
CurrentThread->Priority = THREAD_HIGH_PRIORITY;
|
||||||
CurrentThread->State = Running;
|
CurrentThread->State = Running;
|
||||||
CurrentThread->Affinity = (ULONG_PTR)1 << Prcb->Number;
|
CurrentThread->Affinity = (ULONG_PTR)1 << Prcb->Number;
|
||||||
CurrentThread->WaitIrql = DISPATCH_LEVEL;
|
CurrentThread->WaitIrql = DISPATCH_LEVEL;
|
||||||
CurrentThread->ApcState.Process->ActiveProcessors |= (ULONG_PTR)1 << Prcb->Number;
|
CurrentProcess->ActiveProcessors |= (ULONG_PTR)1 << Prcb->Number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,7 +49,8 @@ KeInitializeThread(IN PKPROCESS Process,
|
|||||||
IN PVOID StartContext,
|
IN PVOID StartContext,
|
||||||
IN PCONTEXT Context,
|
IN PCONTEXT Context,
|
||||||
IN PVOID EnvironmentBlock,
|
IN PVOID EnvironmentBlock,
|
||||||
IN PVOID Stack)
|
IN PVOID Stack,
|
||||||
|
IN BOOLEAN StartThread)
|
||||||
{
|
{
|
||||||
PKWAIT_BLOCK TimerWaitBlock;
|
PKWAIT_BLOCK TimerWaitBlock;
|
||||||
BOOLEAN Allocation;
|
BOOLEAN Allocation;
|
||||||
@ -164,7 +165,13 @@ KeInitializeThread(IN PKPROCESS Process,
|
|||||||
|
|
||||||
/* Mark thread as initialized and run it */
|
/* Mark thread as initialized and run it */
|
||||||
Thread->State = Initialized;
|
Thread->State = Initialized;
|
||||||
KeStartThread(Thread);
|
|
||||||
|
/* Check if thread should be started */
|
||||||
|
if(StartThread)
|
||||||
|
{
|
||||||
|
/* Start thread */
|
||||||
|
KeStartThread(Thread);
|
||||||
|
}
|
||||||
|
|
||||||
/* Return success */
|
/* Return success */
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
Loading…
Reference in New Issue
Block a user