earlysuspend、autosleep以及wakeup_count三種休眠機制的分析和比較,androidautosleep

來源:互聯網
上載者:User

earlysuspend、autosleep以及wakeup_count三種休眠機制的分析和比較,androidautosleep

一、Opportunistic sleep引言

1. 背景

(1) android 面臨的問題

          Opportunistic sleep: 當沒有任務時,需要尋找時機,進入suspended

(2) 3類同步問題

          a. 核心:driver處理event的過程中,系統不能suspend

          b. 使用者:使用者進程處理的過程中系統不能suspend

          c. 核心與使用者互動: 

              休眠過程中,觸發event, 需abort suspend流程;

              event 事件需使用者態處理完畢後,才能suspend;



2. earlysuspend



3. autosleep



4. wakeup_count



5. 三種休眠機制的比較


(1)有關earlysuspend的討論

          a. 更改了suspend 流程,引入了earlysuspend 介面;

          b. 社區對該patch,有誤解,認為其要替代runtime;

          c. wakelock 實現過於複雜,名稱易造成誤解;

          d. mini-summit: 有nokia 開發人員,缺乏android 開發人員,引入了非技術性的討論;

          e. 應該使用pm_runtime, cpuidle; susupend 不應該存在;

          f. 喚醒源的處理過程,貫穿整個系統,影響較大;

(2)有關autosleep的討論

          a. android 市場份額越來越大,很多driver src code 脫離了mainline;

          b. Linus 認為需要合并android 的特性:suspend block;

          c. Rafael J. Wysocki 認為時機已經成熟,提出了新的解決方案;

          d. 社區對該opportunisic suspend patch, 有誤解,引入了非技術性的討論:重新設計後,命名為autosleep;

          e. 考慮到android 的相容性,介面上保留了wakelock; 實現上,進行了改進;


(3)有關wakeup_count的討論

          a. 在userspace 基於wakeup_count 實現的 opportunistic sleep 機制;(與autosleep 類似);

          b. 核心空間,無wake_lock 概念;

          c. 無suspend block 概念;

          d. suspend 觸發的時機,全部交由使用者空間負責;



6. 引入autosleep   |  wakeup count的理由

(1)earlysuspend 被核心拋棄,需自己打補丁;

(2)使用earlysuspend, 對核心改動較大,更改了suspend 流程, 無法合并入mainline;

(3)對裝置驅動影響較大,需額外實現earlysuspend 介面,不利於upstream;

(4)earlysuspend 已存在的問題:例如只支援開關屏時執行earlysuspend, 不利於動態功耗的最佳化;

(5)pm_runtime 已經在display, usb 等裝置使用;

(6)upstream 的需求;


二、opportunistic sleep 架構



三、wakeup source 架構

1. 功能

    a. 抽象wakeup source和wakeup event的概念;

    b. 向各個device driver提供wakeup source的註冊、使能等介面;

    c. 向各個device driver提供wakeup event的上報、停止等介面;

    d. 向上層的PM core(包括wakeup count、auto sleep、suspend、hibernate等模組)提供wakeup event的查詢接

        口,以判斷是否可以suspend、是否需要終止進行中的suspend;


2. 資料結構


(1)registered wakeup events(cnt)和saved_count;

(2)wakeup events in progress(inpr);



3. 相關介面






四、wakeup count架構

1. 目標

    有喚醒事件需處理時:
若系統在運行過程中,不能進入suspend;
若已進入suspend 流程,需及時退出;


2. 介面

    a. bool pm_get_wakeup_count(unsigned int *count, bool block);

    b. bool pm_save_wakeup_count(unsigned int count);


3. 流程





聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.