android 休眠喚醒

來源:互聯網
上載者:User
android v2.3linuxv2.6.37wakelock 和 early_suspend能夠實現系統的喚醒和休眠功能1.wakelockwakelock是一種鎖機制,只要有人拿著這個鎖,系統就無法進入休眠,wakelock有加鎖解鎖二種狀態逾時鎖:在設定的時間到了後自動解鎖不逾時鎖:需要顯示的解鎖include/linux/wakelock.henum {WAKE_LOCK_SUSPEND, //防止系統進入睡眠WAKE_LOCK_IDLE,    WAKE_LOCK_TYPE_COUNT};2.early_suspend 在linux 核心的睡眠過程前被調用,因為背光需要的電能大,可以在核心中先註冊上early_suspend函數當系統進入睡眠之前會首先調用這些註冊的函數android休眠喚醒的的檔案kernel/power/console.cearlysuspend.cfbearlysuspend.cmain.cpoweroff.csuspend.cwakelock.cuserwakelock.carch/arm/mach-omap2/pm34xx.c pm.c3.android 休眠當使用者讀寫/sys/power/state時,/kernel/power/main.c中的state_store()函數會被調用# echo mem > sys/power/state                                                    [   61.009735] ------state_store------                                          [   61.013366] ------request_suspend_state------                                [   61.017944] request_suspend_state: sleep (0->3) at 61399169254 (2000-01-01 00:00:56.084929752 UTC)                                                           [   61.027496] ------early_suspend------ state_store會調用request_suspend_state()然後調用early_suspend_work的工作隊列void request_suspend_state(suspend_state_t new_state){---------------------queue_work(suspend_work_queue, &early_suspend_work);---------------------}static DECLARE_WORK(early_suspend_work, early_suspend);early_suspend_work的工作隊列進入early_suspend()函數中static void early_suspend(struct work_struct *work){-------------------//調用已經註冊的early_suspend函數list_for_each_entry(pos, &early_suspend_handlers, link) {if (pos->suspend != NULL)pos->suspend(pos);}------------------sys_sync();//同步檔案系統}4. android 喚醒# echo on > sys/power/state                                                     [  582.205108] ------state_store------                                          [  582.208740] ------request_suspend_state------                                [  582.213317] request_suspend_state: wakeup (3->0) at 582594543042 (2000-01-01 00:09:37.501769604 UTC)                                                         [  582.222839] ------late_resume------  跟睡眠的過程相反
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.