......so if there's always an init process, why does the kernel have to get executed first??? ....what exactly is the kernel???
well, the kernel creates a task_struct for init, and schedules it on some core to transition to userspace. i suspect the kernel may be able to initialize and even schedule kernel tasks (task_struct, but without the MMU) before then, if it wants.
there are now two points which are very important for the scheduler: process start (transition from other userspace code) and process exit (from user, to kernel!). (note that in this there is absolutely no distinction between multicore and single-core scheduling!)
the following distinctions arrive twofold:
- the core which
init was scheduled on vs exited may differ—this is important for e.g. tracing init's call stack - a task_struct may contain core-specific data (fuck if i know!!), which must be rewritten to form the "core migration" edge
otherwise, everything a kernel should do is in fact not modeled by any unified turing machine model of its own, but rather injects kernel code in response to task-external kernel-specified "fault"s (e.g. page fault) as well as from within the task, upon a syscall. so the total story of a userspace process AFTER initial page mapping is described by the task runtime stack's interaction with the syscall handler–which is possible to record!!!
and so we take no chances—our 2-axis instruction-memory model covers the instruction pointer ranges in kernel code for the duration of the syscall, and the contents of the stack after returning from the syscall are fully contiguous! (this is also true when setting the heap break!)
a fault does not record itself into the userspace process's memory model in this fashion—the effects of the instruction that triggered the fault are reverted.