当前位置:网站首页>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
边栏推荐
- Hash table, generic
- Mac PHP multi version management and swoole extension installation
- This latest research has revealed two secrets of cloudy development
- MySQL_ JDBC
- Simple dialogue system -- implement transformer by yourself
- 3年,我是如何涨薪到20k?
- Day_ thirteen
- [untitled]
- Bombard the headquarters. Don't let a UI framework destroy you
- Problems encountered in using MySQL
猜你喜欢

The first day of reading mysql45

JVM內存結構

二十九-使用RealSenseD435进行ORBSLAM2实时三维重建

A TDD example

Kalman filter meets deep learning: papers on Kalman filter and deep learning

How did I get a salary increase of 13k+ after one year of employment?

論文筆記:LBCF: A Large-Scale Budget-Constrained Causal Forest Algorithm

六大专题全方位优化,阿里巴巴性能优化小册终开源,带你直抵性能极致

揭秘GES超大规模图计算引擎HyG:图切分
![[Jianzhi offer II 091. painting the house]](/img/63/dc54c411b1a2f2b1d69b62edafde38.png)
[Jianzhi offer II 091. painting the house]
随机推荐
Day_ ten
剑指 Offer 50. 第一个只出现一次的字符
Xinlou: Huawei's seven-year building journey of sports health
Bypass technology to talk about 'cross end'
【蓝桥杯集训100题】scratch指令移动 蓝桥杯scratch比赛专项预测编程题 集训模拟练习题第14题
Day21 multithreading
Record learning of hystrix knowledge --20210929
A complete collection of APP testing tools. It's enough to collect this one
效应与定律
【 apprentissage automatique】 cas de prévision et d'analyse de l'examen d'entrée à l'Université basé sur des séries chronologiques multiples
[proficient in high concurrency] deeply understand the basis of C language and C language under assembly
_ 19_ IO stream summary
Day_ fifteen
This latest research has revealed two secrets of cloudy development
IO stream
Uniapp to preview pictures (single / multiple)
批量--07---断点重提
完美洗牌问题
et al和etc区别
Cache architecture scheme of ten million level shopping cart system