Reputation: 1849
I'm looking for the code in the linux kernel (2.4.x) that initializes the first process, pid=0.
Many searches provided many clues, but I still cannot find it.
Any pointers, anyone?
Upvotes: 5
Views: 7059
Reputation: 3949
The first process that the kernel initializes is the swapper process or the idle thread. This thread runs forever. When no other process is active in the system, then this thread [which is cpu_idle() function found in arch/arm/kernel/process.c for the ARM architecture] calls the architecture dependent pm_idle function, which power collapses the CPU until a timer interrupt or some other interrupt wakes it up.
The swapper process [pid=0] is initialized in arch/arm/kernel/init_task.c by the macro INIT_TASK.
Upvotes: 1
Reputation: 239341
The initial task struct is set up by the macro INIT_TASK()
, defined in include/linux/init_task.h
. All other task structs are created by do_fork
.
Upvotes: 11
Reputation: 26940
check out rest_init() at the end
// idle process, pid = 0
cpu_idle(); // never return
Upvotes: 1