Linux 0.01 init task. Back to Kernel001WalkThrough. This code is in Linux 0.01 init/main.c. This code is a conventional ANSI-C main program called from ThirtyTwoBitInitialization. Linus' comment at the head of this program points out that "forking from kernel space will result in NO COPY ON WRITE (!!!), until an execve is executed. This is no problem, but for the stack. This is handled by not letting main() use the stack at all after fork(). Thus, no function calls - which means inline code for fork too, as otherwise we would use the stack upon exit from 'fork()'." main() performs the following tasks in order: ||||time_init||Initialize system clock from CMOS|| ||||tty_init||Initialize the tty subsystem|| ||||trap_init||Initialize trap handlers (divide by zero, etc)|| ||||sched_init||Initialize the scheduler|| ||||buffer_init||Initialize the block device buffer system|| ||||hd_init||Initialize the hard disk interrupt handler|| ||||||Enable interrupts|| ||||||Move to usermode|| ||||||Fork a child to perform init()|| ||||||Enter schedule loop|| init() is a static function in main.c that goes like so: ||||setup()||Read hard drive partition tables.|| ||||||fork a child to execute update(8)|| ||||||Create the usual stdin,stdout,stderr file descriptors for console|| ||||||Display a message indicating the number of buffers and the amount of buffer space available.|| ||||||Fork a child to execute /bin/sh with argv[0]="-" and HOME=/home/root|| ||||||Wait for the child to die and print its exit code.|| ||||sync()||Synchronize I/O operations|| ||||_exit(0)||Terminate||