miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Loading...
Searching...
No Matches
sched_balance.c File Reference
Include dependency graph for sched_balance.c:

Functions

void sched_balance_enqueue (struct thread *t)
void sched_work_steal (void)

Variables

spinlock_t thread_pool_lock

Function Documentation

◆ sched_balance_enqueue()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_work_steal()

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.

Here is the call graph for this function:

Variable Documentation

◆ thread_pool_lock

spinlock_t thread_pool_lock
extern