admin管理员组

文章数量:1658724

众所周知,在android系统的耗电量排行里,cpu的耗电占了比较大的一部分比例,也就是说,cpu的使用率和使用频率将直接或间接的影响电量的分配和使用,但很遗憾,android-sdk中没有为android的开发者提供类似cpu管理的功能,但是当下很多省电类应用或专业的cpu管理软件都提供了cpu的降频甚至是超频的功能,那么这样的功能是如何实现的,本文将详细说明在android环境下调整cpu频率的一些方法,仅供参考。

按照我写文章的风格,在阐述过程和结论之前,都不得不对关键性的概念做一下解释,本文也不例外。

1.CPU的工作频率

单位赫兹或者兆赫兹,具体含义不解释,说实话也不太清楚,不过可以确认一点的是,CPU的工作频率越高,耗电量越大,反之亦然。我们做这个模块省电的终极目标就是降低cpu的工作频率。

2.CPU的调控模式

英文词为:Governor,解释为调速器,控制器。大家都指导android的framework是基于linux平台的,那么cpu的管理体系这块也跟linux基本上一样,其中包括cat命令,和一些文件的读写配置都是基本上差不多的。Linux在管理CPU方面,提供了如下集中调控模式,分别为:

Governor

Select this governor if

How it works

performance

Performance is the only consideration.

Sets the CPU to run at the highest frequency (scaling_max_freq)

powersave

Efficiency is the only consideration

Sets the CPU to run at the lowest frequency (scaling_min_freq)

ondemand

Adaptation to the current load is the main consideration.

Checks the load regularly. When the load rises aboveup_threshold, sets the CPU to run at the highest frequency (scaling_max_freq). When the load falls below the same threshold, sets the CPU to run at the next lowest frequency. Causes less latency than the conservative governor.

conservative

Close adaptation to the current load is the consideration.

Checks the load regularly. When the load rises aboveup_threshold, sets the CPU to run at the next highest frequency. When the load falls belowdown_threshold, sets the CPU to run at the next lowest frequency. Has more latency than the ondemand governor.

userspace

Control by other use

本文标签: 省电过程中android降频CPU