当前位置:网站首页>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
边栏推荐
- Optimization of lazyagg query rewriting in parsing data warehouse
- Effects and laws
- Paper notes: generalized random forests
- Record learning of hystrix knowledge --20210929
- The problem of missing precision of kettle table input components
- Preliminary understanding of JVM
- Differences between et al and etc
- MySQL_ JDBC
- Structure de la mémoire JVM
- Understanding of reflection part
猜你喜欢

A TDD example

Day_ ten

Using pywebio testing, novice testers can also make their own testing tools

Problems encountered in using MySQL

Creating a uniapp project using hbuilder x

深入浅出对话系统——自己实现Transformer

Kalman time series prediction

批量--07---断点重提

Optimization of lazyagg query rewriting in parsing data warehouse

tensorflow 旧版本
随机推荐
Tensorflow old version
二十九-使用RealSenseD435进行ORBSLAM2实时三维重建
What is backbone network
解析数仓lazyagg查询重写优化
JVM內存結構
Ncnn source code learning collection
Are these old system codes written by pigs?
效应与定律
【机器学习】基于多元时间序列对高考预测分析案例
从TiDB上线阿里云的背后,如何看待云数据库的变革趋势
【機器學習】基於多元時間序列對高考預測分析案例
The problem of missing precision of kettle table input components
JVM内存结构
软件测试面试如何正确谈薪
深入浅出对话系统——自己实现Transformer
从业一年,我是如何涨薪13K+?
Redis Series - Overview day1 - 1
【蓝桥杯集训100题】scratch指令移动 蓝桥杯scratch比赛专项预测编程题 集训模拟练习题第14题
Preliminary understanding of JVM
Internship: the annotation under swagger involves the provision of interfaces