怎么解Linux内核温控,Linux Thermal 框架解析

Linux Thermal 是 Linux 系统下温度控制相关的模块,主要用来控制系统运行过程中芯片产生的热量,使芯片温度和设备外壳温度维持在一个安全、舒适的范围。

那下面我们就来一起看看对于温度控制这样一个需求,Linux 内核是怎么实现的。

Thermal 的主要框架

要实现一个温度控制的需求,试想一下我们是不是最少要有获取温度的设备和控制温度的设备这两个最基本的东西?当然附带的也会产生一些使用温度控制设备的策略。

那上面这些东西在 Linux Thermal 框架中怎么体现呢?通过阅读源码我们发现代码中对上面的东西进行了一些抽象。获取温度的设备:在 Thermal 框架中被抽象为 Thermal Zone Device;

控制温度的设备:在 Thermal 框架中被抽象为 Thermal Cooling Device;

控制温度策略:在 Thermal 框架中被抽象为 Thermal Governor;

877423d5625ee6b25bbde38077cff1ff.png

Thermal Zone Device

上面说到 Thermal Zone Device 是获取温度设备的抽象,怎么抽象的?终究我们还是要 RTFSC。

struct thermal_zone_device {

int id;

char type[THERMAL_NAME_LENGTH];

struct device device;

struct thermal_attr *trip_temp_attrs;

struct thermal_attr *trip_type_attrs;

struct thermal_attr *trip_hyst_attrs;

void *devdata;

int trips;

/* 轮询时间 */

int passive_delay;

int polling_delay;

int temperature;

int last_temperature;

int emul_temperature;

int passive;

unsigned int forced_passive;

/* 设备的操作函数 */

struct thermal_zone_device_ops *ops;

const struct thermal_zone_params *tzp;

struct thermal_governor *governor;

struct list_head thermal_instances;

struct idr idr;

struct mutex lock;

struct list_head node;

/* 用来循环处理的 delayed_work */

struct delayed_work poll_queue;

};

struct thermal_zone_device_ops {

/* 绑定函数 */

int (*bind) (struct thermal_zone_device *,

struct thermal_cooling_device *);

int (*unbind

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值