当前位置:网站首页>tasklet api使用
tasklet api使用
2022-06-25 16:34:00 【酸菜。】
#include<linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include<linux/fs.h>
#include<linux/slab.h>
#include<linux/timer.h>//timer_list
#include <linux/sched.h>//jiffies
#include <linux/list.h>//container_of
#include <linux/interrupt.h>
MODULE_AUTHOR("Tan xujia");
MODULE_LICENSE("Dual BSD/GPL");
DECLARE_WAIT_QUEUE_HEAD(wq);
struct tasklettest {
struct tasklet_struct tsklt;;
int count;
};
struct tasklettest *ttest;
void
tasklet_fn(unsigned long data)
{
printk("tasklet_fn\n");
struct tasklettest *p =(struct tasklettest*)data;
if (--(p->count)) {
tasklet_hi_schedule(&p->tsklt);
//tasklet_schedule(&p->tsklt);
} else {
//tasklet_kill(&ttest->tsklt);,在这里用这个会有问题
wake_up_interruptible(&wq);//唤醒
printk("wait up\n");
}
}
static
int __init hello_init (void)
{
printk("hello_init\n");
ttest = (struct tasklettest *)kzalloc(sizeof(*ttest), GFP_KERNEL);
ttest->count = 10;
tasklet_init(&ttest->tsklt, tasklet_fn, (unsigned long)ttest);
tasklet_hi_schedule(&ttest->tsklt);
//tasklet_schedule(&ttest->tsklt);
wait_event_interruptible(wq, !ttest->count);//等待条件满足以后,程序继续往下走
printk("wait event\n");
tasklet_kill(&ttest->tsklt);
return 0;
}
static
void __exit hello_exit (void)
{
//tasklet_kill(&ttest->tsklt);
kfree(ttest);
printk("hello_exit\n");
}
module_init(hello_init);
module_exit(hello_exit);
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
obj-m :=tasklet.o
all:
make -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.* .tmp_versions *.mod *.order *.symvers *.dwo
边栏推荐
- vscode插件自用
- Cache architecture scheme of ten million level shopping cart system
- mysql使用过程中遇到的问题
- App测试工具大全,收藏这篇就够了
- mac php多版本管理以及安装swoole扩展
- XXIX - orbslam2 real-time 3D reconstruction using realsensed435
- 使用PyWebIO测试,刚入门的测试员也能做出自己的测试工具
- Difference between app test and web test
- Kalman time series prediction
- Unity技术手册 - 生命周期旋转RotationOverLifetime-速度旋转RotationBySpeed-外力ExternalForces
猜你喜欢
随机推荐
什么是骨干网
【蓝桥杯集训100题】scratch指令移动 蓝桥杯scratch比赛专项预测编程题 集训模拟练习题第14题
内卷?泡沫?变革?十个问题直击“元宇宙”核心困惑丨《问Ta-王雷元宇宙时间》精华实录...
Wireshark network card cannot be found or does not display the problem
Paper notes: lbcf: a large scale budget constrained causal forest algorithm
解析数仓lazyagg查询重写优化
炮打司令部,别让一个UI框架把你毁了
效应与定律
Problems encountered in using MySQL
Kettle表输入组件精度丢失的问题
Day_ 05
DDD概念复杂难懂,实际落地如何设计代码实现模型?
Differences between et al and etc
How to talk about salary correctly in software testing interview
[100 questions of Blue Bridge Cup intensive training] scratch command mobile Blue Bridge Cup scratch competition special prediction programming question intensive training simulation exercise question
协议和分层次
ncnn源码学习全集
Data type variable operator
Bypass technology to talk about 'cross end'
Mysql database multi table query









