Linux内核编程:Linux2.6内核源码解析_进程遍历
2014-12-07 22:50
405 查看
/* *File : test.c *Author : DavidLin *Date : 2014-12-07pm *Email : linpeng1577@163.com or linpeng1577@gmail.com *world : the city of SZ, in China *Ver : 000.000.001 *history : editor time do * 1)LinPeng 2014-12-07 created this file! * 2) */ #include <linux/init.h> #include <linux/list.h> #include <linux/module.h> #include <linux/sched.h> static int list_init(void) { struct task_struct *task; task = NULL; for_each_process(task) { printk("pid = %d\n", task->pid); } return 0; } static void list_exit(void) { printk("KERNEL MACRO: for_each_process exit\n"); } module_init(list_init); module_exit(list_exit); MODULE_AUTHOR("Linpeng1577"); MODULE_DESCRIPTION("KERNEL 2.6 MACRO STUDY"); MODULE_LICENES(GPL);
这个例程的Makefile文件及测试参考之前博客:
Linux内核编程:从hello world 开始-(1)_C文件编写
Linux内核编程:从hello world 开始-(2)_Makefile文件编写
Linux内核编程:从hello world 开始-(3)_run
1.不过tail -n 3 /var/log/messages 可以改为tail -n 100 /var/log/messages;
2.ps -el 列出所以进程。
相关文章推荐
- Linux内核编程:Linux2.6内核源码解析_进程遍历
- Linux2.6 内核的 Initrd 机制解析
- Linux2.6 内核的 Initrd 机制解析
- Linux2.6 内核的 Initrd 机制解析
- Linux2.6 内核的 Initrd 机制解析
- 解析Linux内核获取当前进程指针的方法
- Linux2.6 内核的 Initrd 机制解析
- Linux2.6 内核的 Initrd 机制解析
- Linux2.6 内核的 Initrd 机制解析
- Linux2.6 内核的 Initrd 机制解析
- Linux2.6 内核的 Initrd 机制解析
- Linux2.6 内核的 Initrd 机制解析
- Linux2.6内核进程创建过程分析
- Linux2.6内核进程创建过程分析
- Linux2.6 内核的 Initrd 机制解析
- Linux2.6 内核的 Initrd 机制解析
- Linux2.6 内核的 Initrd 机制解析
- Linux2.6 内核的 Initrd 机制解析
- Linux2.6 内核的 Initrd 机制解析
- 转载 linux2.6内核进程调度