CoreProcessScheduler: Part Two

Published December 5, 2025

WG02: CoreProcessScheduler: The Process Balancing system

Abstract

Some processes require more CPU time than others. Over time, balancing these demands improves overall system responsiveness and efficiency.

Methodology: Process Time and Run Time.

The scheduler adjusts a process's PTime (Process Time) using its RTime (Run Time). If a process runs more than its allotted share, the system modifies both PTime and RTime, and adjusts the process's affinity accordingly.

UPDATE: A new variable UTime (Usage time) has been introduced to track the total time a process has been running, which helps in determining how much CPU time it should receive next.

Example: C++ Code based on real NeKernel code.

Taken from the develop branch commit 58d2af1:

if (UserProcessHelper::CanBeScheduled(process)) {
  /// ...
  
  if (UserProcessHelper::Switch(process.StackFrame, process.ProcessId)) {
    process.PTime = static_cast<Int32>(process.Affinity);

    if (process.PTime < process.RTime && AffinityKind::kRealTime = process.Affinity) {
      if (process.RTime < (Int32) AffinityKind::kVeryHigh)
        process.RTime = (Int32) AffinityKind::kLowUsage;
      else if (process.RTime < (Int32) AffinityKind::kHigh)
        process.RTime = (Int32) AffinityKind::kStandard;
      else if (process.RTime < (Int32) AffinityKind::kStandard)
        process.RTime = (Int32) AffinityKind::kHigh;

      process.PTime -= process.RTime;
      process.RTime= 0UL;
    }
  }
} else {
  ++process.RTime;
  --process.PTime;
}

Conclusion

This logic dynamically adapts the execution privileges of each process to avoid starvation and ensure real-time constraints are met, while still maintaining fairness across system workloads. The CPS's balancing design reflects the need to handle processes needs accordingly, no process is created equal, and that's a big assumption in the UPS's architecture.

Amlal.

References

  • https://github.com/nekernel-org/nekernel
  • https://github.com/nekernel-org/draft