当前位置:网站首页>Embedded system driver primary [10] - interrupt processing _ lower half mechanism
Embedded system driver primary [10] - interrupt processing _ lower half mechanism
2022-08-07 16:46:00 【imysy_22_】
# First, the upper half and the lower half
Origin:
1. The problem caused by the long execution time of the interrupt handler
2. The interrupt handler of some devices must handle some time-consuming operations
# Second, the tasklet of the lower half mechanism ---- based on soft interrupt
##6.1 Structures
struct tasklet_struct
{
struct tasklet_struct *next;
unsigned long state;
atomic_t count;
void (*func)(unsigned long);
unsigned long data;
};
## 6.2 Define tasklet interrupt bottom half handler
void tasklet_func(unsigned long data);
## 6.3 Initialize tasklet
```c
DECLARE_TASKLET(name, func, data);
/*
Define variables and initialize
Parameters: name: The name of the tasklet in the bottom half of the interrupt
Func: The name of the bottom half of the interrupt handler
data: parameter passed to the interrupt bottom half handler
*/
```
```c
void tasklet_init(struct tasklet_struct *t,void (*func)(unsigned long), unsigned long data)
```
## 6.4 Scheduling tasklets
```c
void tasklet_schedule(struct tasklet_struct *t)
//Parameter: t: structure of tasklet
```
# 3. Tasklet version driven by keys
# Fourth, the workqueue of the lower half mechanism ----- based on kernel threads
##8.1 Work queue structure:
typedef void (*work_func_t)(struct work_struct *work)
struct work_struct {
atomic_long_t data;
struct list_head entry;
work_func_t func;
\#ifdef CONFIG_LOCKDEP
struct lockdep_map lockdep_map;
\#endif
};
##8.2 Define the bottom half of the work queue processing function
void work_queue_func(struct work_struct *work);
##8.3 Initializing the work queue
struct work_struct work_queue;
Initialization: bind the work queue and the bottom half processing function of the work queue
INIT_WORK(struct work_struct * pwork, _func) ;
parameters: pwork: work queue
func: the bottom half of the work queue processing function
## 8.4 Scheduling functions for work queues
bool schedule_work(struct work_struct *work);
# Five, button-driven workqueue version
# Six, the lower half mechanism comparison
Task mechanism
Workqueue ----- Kernel thread can sleep unlimited running time
Exception mechanism ------- Cannot sleep The execution time of the second half should not be too long ( < 1s)
Soft interrupt ---- interface is inconvenient
tasklet ----- When there is no specific delay time requirement
Timer -----When there is a specific delay time request
边栏推荐
- 技术岗面试中的一些常见问题
- 深度学习之 12 循环神经网络RNN
- 网上股票开户和线下开户一样安全吗
- yolov5使用GPU
- OK1028A核心板搭建QT开发环境
- 2022-08-06 第四小组 修身课 学习笔记(every day)
- [Thesis translation and interpretation (1)] Mitigating Confounding Bias in Recommendation via Information Bottleneck
- 5年经验,没听过XFF漏洞
- Web Server 设置缓存响应字段的一些推荐方案
- [21-day learning challenge] data manipulation of doubly linked list
猜你喜欢
随机推荐
手机开证券账户安全吗 如何在手机上开证券账户
基于FTP协议的文件上传与下载
股票账户手机开户安全吗 同花顺开户靠谱吗
Learning a subshell and process of the Shell system
深度学习之 12 循环神经网络RNN
When Oracle11G uses EXP to export, the empty table cannot be exported.
from . import XXX
SAP CRM Fiori 应用 My Opportunity 的分页读取逻辑,在 GM4 - AG3 无法正常工作
详解 SSL(一):网址栏的小绿锁有什么意义?
关于将本地 SAP UI5 应用配置到本地 Fiori Launchpad 的技术实现深入讲解试读版
Oracle commonly used numeric functions
vim 中展示调用栈
常见的海量数据面试题总结
【kali-权限提升】(4.2)社会工程学工具包(上):启动监听设置payload
2.11-2.10 - storage management page type store 2.12 sections 2.13 - period of storage
Analysis of various related architectures of MCU
【kali-权限提升】(4.1)假冒令牌攻击、本地提权:流程
用手机开户买股票安全吗 如何网上基金定投
2.10 - 存储管理 2.11 - 页式存储 2.12 - 段式存储 2.13 - 段页式存储
一文带你了解webrtc基本原理(动手实现1v1视频通话)









