|
miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
|
#include <miniOS/sched/sched.h>#include <miniOS/arch/x86_64/apic.h>#include <miniOS/arch/x86_64/smp.h>#include <miniOS/arch/x86_64/spinlock.h>#include <miniOS/io.h>
Functions | |
| void | sched_balance_enqueue (struct thread *t) |
| void | sched_work_steal (void) |
Variables | |
| spinlock_t | thread_pool_lock |
| void sched_balance_enqueue | ( | struct thread * | t | ) |
sched_balance_enqueue() - Enqueue @t on the CPU with the shortest run queue. @t: Thread to enqueue. Must be in THREAD_BLOCKED state; caller sets RUNNABLE.
Scans g_cpus[0..smp_cpu_count-1] for minimum queue_depth and tail-inserts @t there. If the target CPU differs from the calling CPU, sends a scheduler-kick IPI (SCHEDULER_KICK_VECTOR) to wake it from hlt.
Context: Called from sched_create_thread() with thread_pool_lock NOT held.


| void sched_work_steal | ( | void | ) |
sched_work_steal() - Steal half the work from the busiest CPU.
Called from idle_loop() when the current CPU's run queue is empty. Acquires thread_pool_lock, finds the CPU with the highest queue_depth > 1, steals floor(queue_depth/2) THREAD_RUNNABLE threads, transfers them to the calling CPU's queue.
Context: Called with interrupts enabled (from idle_loop before hlt). Does nothing if no stealable work exists.

|
extern |