tags:

views:

84

answers:

3

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?

+1  A: 

start_kernel()

check out rest_init() at the end

// idle process, pid = 0
cpu_idle();     // never return
dotjoe
Thanks, I was already looking at that page, so now I know I was on the right path.Where in there is the first task_struct created and populated?
Tzafrir
Which process has pid=0? Are you talking about something before `init`?
dotjoe
The problem I was asked to solve was to add a field to task_struct. I'd like to initialize it, and have each fork() copy it, but can't find where the initial value is set.
Tzafrir
At least with the 2.6 kernel, I think `init` always gets pid 0.
Sarah Vessels
maybe sched.c `schedule()`?
dotjoe
`init` always gets a PID of 1. PID zero is the 'idle' process.
Kevin Panko
A: 

I was told elsewhere it is init_idle()

Tzafrir
+2  A: 

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.

caf