本系列文章所编写的驱动源码仓库,欢迎Star~
https://github.com/Mculover666/linux_driver_study。
一、Linux内核定时器编程
Linux内核中,在时钟中断发生后会唤醒 TIMER_SOFTIRQ 软中断,运行当前处理器上到期的所有定时器。
在linux设备驱动编程中,可以利用Linux内核中提供的一组函数或数据结构来完成定时器触发工作或者完成周期性的事务,并且不用关心具体的软件定时器究竟对应怎样的内核和硬件行为。
1. timer_list
Linux内核使用 timer_list 来表示内核定时器,定义在文件 include/linux/timer.h
中。
struct timer_list {
/*
* All fields that change during normal runtime grouped to the
* same cacheline
*/
struct list_head entry