When the system is first brought up, there are no interrupts and the system is
usually in a supervisor state. The kernel will first initialize the platform
base hardware and processor, as well as interrupt controller - jumping into
a user state and starting up exec.
During execs initialization it will prepare a "bootstrap" task structure and add
a vblank interrupt handler to drive pre-emption, which it does by setting the
quantum-expired and switch scheduling flags.
Exec will then initialize all the SINGLETASK resident modules. One of the first
residents to initialize is execs late initialization - which is run after
platform specific modules that may probe and initialize addition processor cores
and timesources, etc., for the system to utilize. On SMP platforms the scheduler
is started on additional cores and set to run an idle task.
After SINGLETASK residents are initialized, DOS is brought up which starts real
boot process. DOS will launch a new process to run the disk boot sequence, and
let the bootstrap task die, triggering the scheduler to begin.
Periodically the system will trigger an interrupt that results in Schedule being
called to see if another task should run. If there is a readytask with the same
or higher priority, and the current task has no pending exception and has used
its time quantum schedule will signify the task should be switched out.
Switch is next called to put the currently running task into a ready state.
Finally Dispatch is called to select the next suitable task and launch it.
Tasks waiting for input from other events, call Wait() and are put into a
waiting task list. When a triggering event for them occurs, they have the
appropriate signal bits set via Signal() and are moved into the ready list,
so that the schedular can allow them to process the events when it is next time
to run.
Under AmigaOS the Exec fields ThisTask, Quantum, Elapsed, IDNestCnt and
TDNestCnt are used to store the scheduling information used by Exec. AROS also
supports SMP based systems, which have per-processor core versions of these
fields so the exec versions are deprecated and unavailable on those
architectures. It is advised to use FindTask(NULL); to determine the current
task in all cases to ensure code compiles for all AROS targets and gets the
correct value. Other scheduling values should not be accessed.