voidmain(void)/* This really IS void, no error here. */ { //资源初始化,不管 mem_init(main_memory_start,memory_end); trap_init(); blk_dev_init(); chr_dev_init(); tty_init(); time_init(); sched_init(); buffer_init(buffer_memory_end); hd_init(); floppy_init(); sti(); //强制使用内联汇编将手动初始化的0号进程切换特权级到用户态 move_to_user_mode(); //子进程,fork函数返回0则是子进程,否则就是父进程拿到了子进程的pid //C语言中0标识false if (!fork()) { /* we count on this going ok */ //子进程执行了init init(); } /* * NOTE!! For any other task 'pause()' would mean we have to get a * signal to awaken, but task0 is the sole exception (see 'schedule()') * as task 0 gets activated at every idle moment (when no other tasks * can run). For task0 'pause()' just means we go check if some other * task can run, and if not we return here. */ for(;;) pause(); }