Dedicated Idle process and thread initialization with dynamic affinity allocation
This commit is contained in:
@@ -9,6 +9,21 @@
|
||||
#include <xtos.hh>
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the pointer to the global Idle process.
|
||||
*
|
||||
* @return Returns a pointer to the Idle process.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
PKPROCESS
|
||||
KE::KProcess::GetIdleProcess(VOID)
|
||||
{
|
||||
/* Return pointer to the idle process */
|
||||
return &InitialProcess.ProcessControlBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a pointer to the system's initial executive process object.
|
||||
*
|
||||
@@ -23,6 +38,55 @@ KE::KProcess::GetInitialProcess(VOID)
|
||||
return &InitialProcess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the system-wide Idle Process.
|
||||
*
|
||||
* @param Process
|
||||
* Supplies a pointer to the KPROCESS structure representing the idle process.
|
||||
*
|
||||
* @param DirectoryTable
|
||||
* Supplies a pointer to the initial hardware page directory table for the process.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
VOID
|
||||
KE::KProcess::InitializeIdleProcess(IN OUT PKPROCESS Process,
|
||||
IN PULONG_PTR DirectoryTable)
|
||||
{
|
||||
ULONG AffinitySize, MapSize;
|
||||
PACPI_SYSTEM_INFO SysInfo;
|
||||
|
||||
/* Retrieve hardware topology from ACPI */
|
||||
HL::Acpi::GetSystemInformation(&SysInfo);
|
||||
|
||||
/* Calculate the required size for KAFFINITY_MAP structures */
|
||||
AffinitySize = (SysInfo->CpuCount + 63) / 64;
|
||||
MapSize = sizeof(KAFFINITY_MAP) + (AffinitySize * sizeof(KAFFINITY));
|
||||
|
||||
/* Align size to the 8-byte boundary */
|
||||
MapSize = (MapSize + 7) & ~7;
|
||||
|
||||
/* Allocate the process-level affinity structures */
|
||||
MM::Allocator::AllocatePool(NonPagedPool, MapSize, (PVOID*)&Process->Affinity);
|
||||
MM::Allocator::AllocatePool(NonPagedPool, MapSize, (PVOID*)&Process->ActiveProcessors);
|
||||
|
||||
/* Zero the process-level affinity structures */
|
||||
RTL::Memory::ZeroMemory(Process->Affinity, MapSize);
|
||||
RTL::Memory::ZeroMemory(Process->ActiveProcessors, MapSize);
|
||||
|
||||
/* Initialize size metadata */
|
||||
Process->Affinity->Count = (USHORT)AffinitySize;
|
||||
Process->Affinity->Size = (USHORT)AffinitySize;
|
||||
Process->ActiveProcessors->Size = (USHORT)AffinitySize;
|
||||
|
||||
/* Initialize Idle process */
|
||||
KE::KProcess::InitializeProcess(Process, 0, DirectoryTable, FALSE);
|
||||
Process->Quantum = MAXCHAR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the process.
|
||||
*
|
||||
@@ -49,7 +113,6 @@ XTAPI
|
||||
VOID
|
||||
KE::KProcess::InitializeProcess(IN OUT PKPROCESS Process,
|
||||
IN KPRIORITY Priority,
|
||||
IN KAFFINITY Affinity,
|
||||
IN PULONG_PTR DirectoryTable,
|
||||
IN BOOLEAN Alignment)
|
||||
{
|
||||
@@ -68,11 +131,6 @@ KE::KProcess::InitializeProcess(IN OUT PKPROCESS Process,
|
||||
Process->BasePriority = Priority;
|
||||
Process->AutoAlignment = Alignment;
|
||||
|
||||
/* Initialize KAFFINITY_MAP for single-group affinity */
|
||||
Process->Affinity.Count = 1;
|
||||
Process->Affinity.Size = 1;
|
||||
Process->Affinity.Bitmap[0] = Affinity;
|
||||
|
||||
/* Set directory tables */
|
||||
Process->DirectoryTable[0] = DirectoryTable[0];
|
||||
Process->DirectoryTable[1] = DirectoryTable[1];
|
||||
|
||||
Reference in New Issue
Block a user