Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How does the kernel know what to run after it's done w/ hw?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
no_hope
Guru
Guru


Joined: 23 Jun 2003
Posts: 482

PostPosted: Thu Nov 09, 2006 5:10 am    Post subject: How does the kernel know what to run after it's done w/ hw? Reply with quote

Sorry for the lame Subject. My brain's pretty fried from doing homework and running out of space in the subject didn't make it better :(

I am trying get basic understanding of what happens during system boot-up.

Here's the sequence of events as I understand it. Please comment/correct on what I have and help me figure out the missing pieces.

1. Power on
2. BIOS resets all hardware, does basic hardware checks
3. BIOS looks into MBR on the disk it's configured to boot from and executes something there, let's say it's grub
??? does grub load it's own little "kernel" with drivers for the hard drive, keyboard, video, file system, etc.?
4. Grub reads its config file, sees my bzImage there, unpacks it, loads it somewhere in memory
5. Grub executes some kind of jump instruction which jumps into the kernel. CPU will never see grub instructions that are in memory at that moment again
6. Kernel goes through its initiation routine: loads drivers, initializes data structures, etc
7. Kernel runs some program from the filesystem. Is that the program that prints
Code:
INIT: version 2.86 booting
Gentoo Linux...
Copyright...
Press I to enter interactive boot mode

??? This is my main question: what program does the kernel run? How does it know what to run? What happens if that program exits?
??? I noticed that before the aforementioned output, keystrokes aren't echoed to the screen, so presumably whatever does the echoing isn't running yet. What is that program?

Thanks a lot
Back to top
View user's profile Send private message
salahx
Guru
Guru


Joined: 12 Mar 2005
Posts: 559

PostPosted: Thu Nov 09, 2006 5:19 am    Post subject: Reply with quote

2 ways:

Either the kernel runs the program listed on the init= kernel command line, or, if that is absent (which it normally is) run runs one of the hard-coded programs in init/main.c (see you kernel sources in /usr/src/linux, its at the every bottom of that file).

If it cannot find init after exhausting all alternative, the kernel will panic. Init NEVER exitsL: if, for any areason, init dies the kernel will panic. Init is not subject to ptrace(), kill -9, and lots of other stuff, it is "special".
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum