Hi All,
    I would be very thankful if anybody continues this discussion on linux 
runlevels......(sysvinit package)
I want to unveil the sysvinit package that how it works. I have given some 
understanding of mine of sysinit package

please bear with me.

Again thanks in anticipation.

According to my little understanding of sysvinit package and kernel source :

    Process 0 (the process which starts  init(1), kflushd(2), kpiod(3), kswapd(4), 
mdrecovery(5) ) and then ends
with scheduler(please confirm). This init is the main in init.c of sysvinit package.

This first takes "init" as to its own name or any command line name then it checks 
that whether it has to re-exec
( what is re-exec ), for this it checks the state pipe (11) if there is some state 
passed on then it receives the
state if it is not C_VER(small description of Tokens needed) then it returns failure 
or it searches in CHILD that
to which child it is (not very sure). If it is not reexec then it checks for telinit 
or init command line
parameters. In both cases it calls init_main().
 /* Nope, this is a change-run-level init */.....can anybody please clarify the code 
below this line in main.

Well coming to init_main() this is a function

This checks for that whether this is a reload or not (what is diff between reload and 
rexec). If it is a not a
reload then it does a soft reboot (where is src code of reboot system call ). then it 
opens the master virtual
termainal and asks him to accept the signals...after that it ignores all the 
signals(Why ??) ...if reload ends
here.
In any case reload or not, it initializes some signals and thier respective signal 
handlers.(There is a NOTE here
if anyone can explain it to me) then it initializes the console (i.e. it gets a 
console or a vt else it makes the
console as /dev/null.)

Here again comes the reload or not if.

If it is not a reload then it close 0,1,2 (Why ??) and then it sets the term ( this 
means that it saves the term
settings if needed and then it initialises to some most common configurations of tty 
or restores the configurations
of tty )
then it setsid (what is it..I read it but not very sure of this)...session is 
created.Then it makes path variable.
Then it makes utmp for logging.
Declares a bootmsg and then if emergency shell needed then it spawns it (What is 
emergency shell ??) otherwise it
sets the runlevel to '#' and reads inittab for intiating accrding to runlevel.

else if it is a reload then it unblocks all signals (Why ??)
and calls start_if_needed ( it checks for this process(childs) that whether it is 
waiting or running If waiting the
break from the child list or continue.
It then startsup a child if needed on demand or tries to delete it....Checks that 
whether it is POWER or it is a
request from keyboard otherwise we wait for this process also (This funtion is not 
very clear to me))

Now it enters a infinite while loop
It calls boot_transitions if there is a transition from single user to multiuser 
mode.If there are no childs then
it switches to the runlevel SYSINIT or NORMAL or SU MODE
In either of three cases it saves the terminal settings, defines new runlevel as 
wanted runlevel or default
runlevel fron inittab file..in single user mode it also makes all childs as not 
failing/waiting/xecuted (Why ??)

Then it logs famous "Entering runlevel :" into syslog and console. after that it 
writes to utmp/wtmp then it sets
the proc title as init[runlevel]..so this was boot_transitions.

after that we check to see whether child is running and not ready to BOOT, if yes the 
then break from child list.
after this it checks_init_fifo(What is this for)

Then it checks whether child is failing or not, if it is then we see whether we can 
free this or not we fix the
next alarm. If it is a next alarm then we alarm (system call)
the clock.

then process_signals and then call start_if_needed
end of while loop and init_main.



Thanks for bearing me.

- Gaurav.


> CHANGING RUNLEVELS
>        After  it  has spawned all of the processes specified, init waits for one of 
>its descendant processes to
>        die, a powerfail signal, or until it is signaled by telinit to change the 
>system's runlevel.   When  one
>        of the above three conditions occurs, it re-examines the /etc/inittab file.  
>New entries can be added to
>        this file at any time.  However, init still waits for one of the above three 
>conditions  to  occur.   To
>        provide  for  an  instantaneous  response, the telinit Q or q command can 
>wake up init to re-examine the
>        /etc/inittab file.
>
> Have you changed the default runlevel in /etc/inittab to 5 and done
> init q
> before running telinit or init 5
>

--
|-------------------------------------------------|
|                    GAURAV                       |
|-------------------------------------------------|
| Please feel free to                             |
| mailto:[EMAIL PROTECTED] (Office Email-id) |
| or (at Other Email-ids)                         |
| mailto:[EMAIL PROTECTED]                   |
| mailto:[EMAIL PROTECTED]                     |
|-------------------------------------------------|
|    L  o  v  e  r     o  f     1  I  N  U  X     |
|     Open Invit to all....to talk on 1INUX       |
|-------------------------------------------------|



-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.linux-learn.org/faqs

Reply via email to