#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/list.h>
int __init sched_fun_init()
{
struct task_struct *p, *ts = &init_task;
struct list_head *pos;
int count = 0;
list_for_each(pos, &ts->tasks) {
p = list_entry(pos, struct task_struct,tasks);
count++;
printk("<1> pid = %ld----%s\n", p->pid, p->comm);
}
printk("<1> count = %d\n", count);
}
void __init sched_fun_exit()
{
printk("<1> sched_fun_exit\n");
}
module_init(sched_fun_init);
module_exit(sched_fun_exit);
obj-m += sched_class.o # 产生hellomod 模块的目标文件
CURRENT_PATH := $(shell pwd) #模块所在的当前路径
LINUX_KERNEL := $(shell uname -r) #Linux内核源代码的当前版本
LINUX_KERNEL_PATH := /usr/src/linux-$(LINUX_KERNEL) #Linux内核源代码的绝对路径
all:
make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) modules #编译模块了
clean:
make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) clean #清理