当前位置:网站首页>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
边栏推荐
- Do you know all the configurations of pychrm?
- Record learning of hystrix knowledge --20210929
- [proficient in high concurrency] deeply understand the basis of C language and C language under assembly
- 解析数仓lazyagg查询重写优化
- Notes: lbcf: a Large Scale budget Constrained causal Forest Algorithm
- Xinlou: Huawei's seven-year building journey of sports health
- Process control and method
- App测试和Web测试的区别
- 炮打司令部,别让一个UI框架把你毁了
- Paper notes: generalized random forests
猜你喜欢

mac php多版本管理以及安装swoole扩展

This latest research has revealed two secrets of cloudy development

vscode插件自用

tensorflow 旧版本

Day_ 16 set

炮打司令部,别让一个UI框架把你毁了

The third day of mysql45

Read mysql45 - a simple understanding of global locks and table locks

【NLP】今年英语高考,CMU用重构预训练交出134高分,大幅超越GPT3

「津津乐道播客」#386 原汤话原食:谁还不是个“白字先生”?
随机推荐
Reading mysql45 lecture - index continued
Problems encountered in using MySQL
这项最新的调查研究,揭开多云发展的两大秘密
加密潮流:时尚向元宇宙的进阶
IO stream
Using pywebio testing, novice testers can also make their own testing tools
Generate post order traversal according to pre order traversal and mid order traversal
2021, committed to better development
Collection overview, array encapsulation
深入理解和把握数字经济的基本特征
Do you know all the configurations of pychrm?
Android修行手册之Kotlin - 自定义View的几种写法
Day_ seventeen
【无标题】
Wireshark network card cannot be found or does not display the problem
mysql使用过程中遇到的问题
Understanding of reflection part
ncnn源码学习全集
tensorflow 旧版本
Paper notes: generalized random forests