One of the last init steps while the OS boots in single threaded mode (See boot_process and init_overview).
All processes will get created by loading an ELF file from disk and setting up the memory layout for the user process based on the metadata from the ELF file.
All processes but the first one. The problem is that the final steps of the init_filesystem need to happen in a process (to call wait()
), so there is no file system to load the ELF of the first process.
init_userspace()
builds the first process "manually":
alloc_process()
creates the first process- Virtual memory is setup (see memory_management)
- The code is copied from a static array which was generated by assembling
initcode.S
and dumping the code segment into a header file (initcode.h
).
The scheduler (see scheduling) will select this process and switch to user mode.
All the initcode does is call execv to execute
/init.
initcode
is not expected to return
/usr/bin/init
sets up console IO for its child processes (all processes in this case) and starts a shell which then can fork and execv applications. For details see init.
Overview: kernel
Boot: boot_process | init_overview
Subsystems: interrupts | devices | file_system | memory_management processes | scheduling | syscalls