Linux hibernate的简单过程

来源:互联网 发布:詹姆斯12年总决赛数据 编辑:程序博客网 时间:2024/06/10 00:43

这几天应上级只要求,survey一下Linux的hibernate,侧重于CPU的operation。

 

有一份PPT可以参考,可惜不能下载,链接是:

http://www.slideshare.net/varunmahajan06/hibernation-linux-2629

进去之后,如果有问题,那你自己在网站中search“Linux Hibernate”这2个关键字,就能找到。

 

 

另外,我整理出了一个简单的代码树,供大家参考。


hibernate    (kernel/power/hibernate.c)
    |- hibernation_snapshot
    |    |- create_images
    |        |- disable_nonboot_cpus        (kernel/cpu.c)
    |        |    |- _cpu_down
    |        |    |    |- take_cpu_down
    |        |    |    |    |- __cpu_disable    (arch/x86/include/asm/smp.h)    // Ensure this CPU doesn't handle any more interrupts
    |        |    |    |        |- native_cpu_disable    (arch/x86/kernel/Smpboot.c)
    |        |    |    |- __cpu_die    (arch/x86/include/asm/smp.h)    // This actually kills the CPU
    |        |    |        |- native_cpu_die    (arch/x86/kernel/Smpboot.c)
    |        |    |
    |        |    |- cpumask_set_cpu    (include/linux/cpumask.h)
    |        |   
    |        |- in_suspend = 1;
    |        |
    |        |- save_processor_state        (arch/x86/power/cpu.c)
    |        |    |- __save_processor_state
    |        |
    |        |- swsusp_arch_suspend    (arch/x86/power/hibernate_asm_32.S)
    |        |    |- swsusp_save    (kernel/power/snapshot.c)
    |        |
    |        |- restore_processor_state    (arch/x86/power/cpu.c)
    |        |
    |        |- enable_nonboot_cpus        (kernel/cpu.c)
    |
    |-     if (in_suspend)
        {
            swsusp_write;
            power_down;
            in_suspend = 0;
        }

   

   
software_resume    (kernel/power/hibernate.c)
    |- hibernation_restore        // If successful, control returns after hibernation_snapshot->create_images->swsusp_arch_suspend
        |- resume_target_kernel
            |- disable_nonboot_cpus        (kernel/cpu.c)
            |- swsusp_arch_resume        (arch/x86/power/Hibernate_32.c)   
            |    |- restore_image    (arch/x86/power/hibernate_asm_32.S)
            |- // The code below is only ever reached in case of a failure.

 

 

 

原创粉丝点击