当前位置:网站首页>Tasklet API usage
Tasklet API usage
2022-06-25 16:58:00 【pickled cabbage】
#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);, There will be problems with this here
wake_up_interruptible(&wq);// Wake up the
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);// Wait until the conditions are met , The program continues
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
边栏推荐
- Process control and method
- Vscode plug-in self use
- 2022-06-17 网工进阶(九)IS-IS-原理、NSAP、NET、区域划分、网络类型、开销值
- Ten thousand volumes - list of Dali wa
- Day_ 05
- Wireshark网卡无法找到或没有显示的问题
- vscode插件自用
- How did I get a salary increase of 13k+ after one year of employment?
- Xinlou: un voyage de sept ans de Huawei Sports Health
- 剑指 Offer 39. 数组中出现次数超过一半的数字
猜你喜欢
随机推荐
Understanding of reflection part
Mac PHP multi version management and swoole extension installation
[untitled]
【精通高并发】深入理解汇编语言基础
20省市公布元宇宙路线图
Day_ 05
DDD概念复杂难懂,实际落地如何设计代码实现模型?
一个 TDD 示例
Day_ ten
2022-06-17 advanced network engineering (IX) is-is- principle, NSAP, net, area division, network type, and overhead value
【效率】又一款笔记神器开源了!
Tensorflow old version
SDN系统方法 | 10. SDN的未来
The art of code annotation. Does excellent code really need no annotation?
Apijson simple to use
3. conditional probability and independence
数字经济时代文化消费新特征
Do you know all the configurations of pychrm?
Day_ eleven
深入浅出对话系统——自己实现Transformer








