Init进程启动.docVIP

  • 3
  • 0
  • 约2万字
  • 约 18页
  • 2017-01-05 发布于贵州
  • 举报
Init进程启动Init进程启动

Init进程启动 asmlinkage void __init start_kernel(void) { .......................................... rest_init(); } static noinline void __init_refok rest_init(void) __releases(kernel_lock) { int pid; rcu_scheduler_starting(); /* * We need to spawn init first so that it obtains pid 1, however * the init task will end up wanting to create kthreads, which, if * we schedule it before we create kthreadd, will OOPS. */ kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); numa_default_policy(); pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES); rcu_read_lock(); kthreadd_task = find_task_by_pid_ns(pid, init_pid_ns); rcu_read_unlock(); complete(kthreadd_done); unlock_kernel(); /* * The boot idle thread must execute schedule() * at least once to get things moving: */ init_idle_bootup_task(current); preempt_enable_no_resched(); schedule(); preempt_disable(); /* Call into cpu_idle with preempt disabled */ cpu_idle(); } static int __init kernel_init(void * unused) { /* * Wait until kthreadd is all set-up. */ wait_for_completion(kthreadd_done); lock_kernel(); do_basic_setup(); .................................................. init_post(); return 0; } static noinline int init_post(void) __releases(kernel_lock) { /* need to finish all async __init code before freeing the memory */ async_synchronize_full(); free_initmem(); unlock_kernel(); mark_rodata_ro(); system_state = SYSTEM_RUNNING; numa_default_policy(); current-signal-flags |= SIGNAL_UNKILLABLE; if (ramdisk_execute_command) { run_init_process(ramdisk_execute_command); printk(KERN_WARNING Failed to execute %s\n, ramdisk_execute_command); } /* * We try each of these until one succeeds. * * The Bourne shell can be used instead of init if we are * trying to recover a really broken machine. */ if (execute_command) { run_init_process(execute_command); printk(KERN_WARNING Failed to execute %s. Attempting defaults...\n,

文档评论(0)

1亿VIP精品文档

相关文档