mirror of
https://github.com/justinian/jsix.git
synced 2025-12-11 08:54:31 -08:00
[kernel] Schedule threads on other CPUs
Now that the other CPUs have been brought up, add support for scheduling tasks on them. The scheduler now maintains separate ready/blocked lists per CPU, and CPUs will attempt to balance load via periodic work stealing. Other changes as a result of this: - The device manager no longer creates a local APIC object, but instead just gathers relevant info from the APCI tables. Each CPU creates its own local APIC object. This also spurred the APIC timer calibration to become a static value, as all APICs are assumed to be symmetrical. - Fixed a bug where the scheduler was popping the current task off of its ready list, however the current task is never on the ready list (except the idle task was first set up as both current and ready). This was causing the lists to get into bad states. Now a task can only ever be current or in a ready or blocked list. - Got rid of the unused static process::s_processes list of all processes, instead of trying to synchronize it via locks. - Added spinlocks for synchronization to the scheduler and logger objects.
This commit is contained in:
@@ -43,8 +43,7 @@ class lapic :
|
||||
public:
|
||||
/// Constructor
|
||||
/// \arg base Physicl base address of the APIC's MMIO registers
|
||||
/// \arg spurious Vector of the spurious interrupt handler
|
||||
lapic(uintptr_t base, isr spurious);
|
||||
lapic(uintptr_t base);
|
||||
|
||||
/// Get the local APIC's ID
|
||||
uint8_t get_id();
|
||||
@@ -93,19 +92,14 @@ public:
|
||||
void calibrate_timer();
|
||||
|
||||
private:
|
||||
inline uint64_t ticks_to_us(uint32_t ticks) const {
|
||||
return static_cast<uint64_t>(ticks) / m_ticks_per_us;
|
||||
}
|
||||
|
||||
inline uint64_t us_to_ticks(uint64_t interval) const {
|
||||
return interval * m_ticks_per_us;
|
||||
}
|
||||
inline static uint64_t ticks_to_us(uint64_t ticks) { return ticks / s_ticks_per_us; }
|
||||
inline static uint64_t us_to_ticks(uint64_t interval) { return interval * s_ticks_per_us; }
|
||||
|
||||
void set_divisor(uint8_t divisor);
|
||||
void set_repeat(bool repeat);
|
||||
|
||||
uint32_t m_divisor;
|
||||
uint32_t m_ticks_per_us;
|
||||
static uint64_t s_ticks_per_us;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user