|
ginnOS
The reference: libc, the libraries and the kernel
|
Go to the source code of this file.
Macros | |
| #define | SCHED_TIME_SLICE 2 |
| number of PIT ticks per scheduling time slice (~20ms at 100Hz). | |
Functions | |
| void | scheduler_init (void) |
| initialize the scheduler. | |
| bool | scheduler_run_core (void) |
| make the code that runs the call the idle task of its core, and run processes on the core from now on. | |
| void | scheduler_ready (process_t *proc) |
| add a process to a run queue: the queue of the core it last ran on, or of an idle core (scheduler.c). | |
| void | scheduler_remove (process_t *proc) |
| remove a process from its run queue. | |
| void | scheduler_kick (process_t *proc) |
| make a process that runs on another core enter the kernel now (a reschedule IPI), so that it acts on a new signal at once and not at the end of its time slice (Linux's kick_process). | |
| void | scheduler_ready_locked (process_t *proc) |
| scheduler_ready() for a caller that holds sched_lock. | |
| void | scheduler_remove_locked (process_t *proc) |
| scheduler_remove() for a caller that holds sched_lock. | |
| process_t * | scheduler_pull_locked (cpu_t *cpu, uint32_t min_load) |
| move the process at the head of the queue of the busiest other core to the queue of a core (load balancing). | |
| void | schedule_locked (void) |
| switch to the next ready process. | |
| void | scheduler_unlock (uint32_t flags) |
| release sched_lock and restore the interrupt state. | |
| void | scheduler_finish (uint32_t flags) |
| scheduler_unlock() after schedule_locked(): it also frees the orphans that exited on the stack this core left. | |
| void | scheduler_tail (void) |
| the first call of a new process (the idle task, the start of a program, a fork child): release the sched_lock that the switch to it holds. | |
| void | scheduler_tick (void) |
| called from the PIT IRQ handler on every tick. | |
| void | scheduler_yield (void) |
| voluntarily yield the CPU to the next ready process. | |
| bool | scheduler_is_active (void) |
| check whether the scheduler has started switching processes. | |
Variables | |
| spinlock_t | sched_lock |
| the lock of the run queues, the state of each process and the list of each wait queue. | |
| #define SCHED_TIME_SLICE 2 |
number of PIT ticks per scheduling time slice (~20ms at 100Hz).
| void scheduler_init | ( | void | ) |
initialize the scheduler.
must be called after process_init().
| bool scheduler_run_core | ( | void | ) |
make the code that runs the call the idle task of its core, and run processes on the core from now on.
call it once on each core other than the boot core, with interrupts off, after scheduler_init().
| void scheduler_ready | ( | process_t * | proc | ) |
add a process to a run queue: the queue of the core it last ran on, or of an idle core (scheduler.c).
an idle core gets a reschedule IPI.
| proc | the process to enqueue. |
| void scheduler_remove | ( | process_t * | proc | ) |
remove a process from its run queue.
used when a process exits or blocks.
| proc | the process to remove. |
| void scheduler_kick | ( | process_t * | proc | ) |
make a process that runs on another core enter the kernel now (a reschedule IPI), so that it acts on a new signal at once and not at the end of its time slice (Linux's kick_process).
nothing is done for a process that does not run, or that runs on this core.
| proc | the process. |
| void scheduler_ready_locked | ( | process_t * | proc | ) |
scheduler_ready() for a caller that holds sched_lock.
| proc | the process to enqueue. |
| void scheduler_remove_locked | ( | process_t * | proc | ) |
scheduler_remove() for a caller that holds sched_lock.
| proc | the process to remove. |
move the process at the head of the queue of the busiest other core to the queue of a core (load balancing).
the load of a core is the processes in its queue, plus one if it runs a process.
| cpu | the core that takes the process. |
| min_load | the least load that the busiest core must have. |
| void schedule_locked | ( | void | ) |
switch to the next ready process.
call it with sched_lock held and interrupts masked. it returns when this process runs again, with sched_lock held again (by the core that switched back to it).
| void scheduler_unlock | ( | uint32_t | flags | ) |
release sched_lock and restore the interrupt state.
| flags | the value from spin_lock_irqsave(&sched_lock). |
| void scheduler_finish | ( | uint32_t | flags | ) |
scheduler_unlock() after schedule_locked(): it also frees the orphans that exited on the stack this core left.
| flags | the value from spin_lock_irqsave(&sched_lock). |
| void scheduler_tail | ( | void | ) |
the first call of a new process (the idle task, the start of a program, a fork child): release the sched_lock that the switch to it holds.
| void scheduler_tick | ( | void | ) |
called from the PIT IRQ handler on every tick.
decrements the time slice counter and triggers a context switch when the slice expires.
| void scheduler_yield | ( | void | ) |
voluntarily yield the CPU to the next ready process.
can be called from kernel code (e.g. when a process blocks).
| bool scheduler_is_active | ( | void | ) |
check whether the scheduler has started switching processes.
it starts with the first scheduler_ready(); until then (the first /bin/sh runs on the boot stack) scheduler_yield() returns at once, so nothing can block.
|
extern |
the lock of the run queues, the state of each process and the list of each wait queue.
the innermost lock: take no other lock while it is held. take it with spin_lock_irqsave() and release it with scheduler_unlock().