Simple CPU affinity system

This commit is contained in:
Alex 2023-02-25 03:58:11 +02:00
parent 14aa071e7f
commit 5e72d81a8f
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
2 changed files with 17 additions and 3 deletions

View File

@ -140,6 +140,9 @@ namespace Tasking
if (tcb->Status != TaskStatus::Ready)
continue;
if (tcb->Info.Affinity[CurrentCPU->ID] == false)
continue;
CurrentCPU->CurrentProcess = pcb;
CurrentCPU->CurrentThread = tcb;
return true;
@ -178,6 +181,9 @@ namespace Tasking
goto RetryAnotherThread;
}
if (thread->Info.Affinity[CurrentCPU->ID] == false)
continue;
CurrentCPU->CurrentThread = thread;
gnat_schedbg("[thd 0 -> end] Scheduling thread %d parent of %s->%d Procs %d", thread->ID, thread->Parent->Name, CurrentCPU->CurrentProcess->Threads.size(), ListProcess.size());
return true;
@ -238,6 +244,9 @@ namespace Tasking
continue;
}
if (tcb->Info.Affinity[CurrentCPU->ID] == false)
continue;
CurrentCPU->CurrentProcess = pcb;
CurrentCPU->CurrentThread = tcb;
gnap_schedbg("[cur proc+1 -> first thd] Scheduling thread %d %s->%d (Total Procs %d)", tcb->ID, tcb->Name, pcb->Threads.size(), ListProcess.size());
@ -290,6 +299,9 @@ namespace Tasking
continue;
}
if (tcb->Info.Affinity[CurrentCPU->ID] == false)
continue;
CurrentCPU->CurrentProcess = pcb;
CurrentCPU->CurrentThread = tcb;
sspt_schedbg("[proc 0 -> end -> first thd] Scheduling thread %d parent of %s->%d (Procs %d)", tcb->ID, tcb->Parent->Name, pcb->Threads.size(), ListProcess.size());

View File

@ -741,8 +741,8 @@ namespace Tasking
{
SmartCriticalSection(TaskingLock);
#if defined(__amd64__)
for (int i = 0; i < SMP::CPUCores; i++)
((APIC::APIC *)Interrupts::apic[i])->RedirectIRQ(i, CPU::x86::IRQ16 - CPU::x86::IRQ0, 1);
// Map the IRQ16 to the first CPU.
((APIC::APIC *)Interrupts::apic[0])->RedirectIRQ(0, CPU::x86::IRQ16 - CPU::x86::IRQ0, 1);
#elif defined(__i386__)
#elif defined(__aarch64__)
#endif
@ -812,7 +812,9 @@ namespace Tasking
sprintf(IdleName, "Idle Thread %d", i);
IdleThread->Rename(IdleName);
IdleThread->SetPriority(Idle);
break;
for (int j = 0; j < MAX_CPU; j++)
IdleThread->Info.Affinity[j] = false;
IdleThread->Info.Affinity[i] = true;
}
debug("Tasking Started");
#if defined(__amd64__)