linux 添加内核模块
模块是LINUX特有的一种机制,可以动态的增加内核的功能
可以作为独立程序来编译,但可以随时被链接到内核中,成为内核的一部分(INSMOD ./[模块名].ko),也可以被卸载(RMMOD ./[模块名].ko),模块简单灵活,相比系统调用,避免了编译和启动内核的麻烦,却一样可以再和心态工作。
下面写写个例子
列出某进程家族的信息,包括子进程,兄弟进程,和子进程
输出程序名,PID号。
下面用到两个宏list_entry 和list_for_each
详细用法请参看LINUX-KERNEL 2。4 的文档
#include <linux/init.h>
#include<linux/module.h>
#include<linux/sched.h>
#include<linux/string.h>
#include <linux/prefetch.h>
MODULE_LICENSE("GPL");
static int tpid=1;
module_param(tpid, int, S_IRUGO);
MODULE_PARM_DESC(tpid, "The pid of the task");
static int list_family_init(void){
struct task_struct *task_ptr=find_task_by_pid(tpid);
//*******************************************Father!!******************************************************************//
printk(KERN_ALERT"Task father info :\n\t Father PID = %ld is executing program %s \n",task_ptr->parent->pid,task_ptr->parent->comm);
//*******************************************************************************************************************//
//*******************************************Children!!***************************************************************//
/* list_entry(task_ptr,task_struct,children);
struct list_head *pos;
struct list_head *head=task_ptr->children;
for (pos = (head)->next; prefetch(pos->next), pos != (head);pos = pos->next)
{
printk(KERN_ALERT"Task children info :\n\t Children PID = %d is executing program %s \n",pos->pid,pos->comm);
}
*/
struct list_head * temp_ptr;
struc
相关文档:
Service Discovery Protocol(SDP)提供一种能力,让应用程序有方法发现哪种服务可用以及这种服务的特性。
服务发现协议(SDP或Bluetooth SDP)在蓝牙协议栈中对蓝牙环境中的应用程序有特殊的含意,发现哪个服务是可用的和确定这些可用服务的特征。SDP定义了bluetooth client发现可用bluetooth server服务和它们的特征的方法。 ......
一:前言
最近在研究android的sensor driver,主要是E-compass,其中用到了Linux input子系统.在网上也看了很多这方面的资料,感觉还是这篇分析的比较细致透彻,因此转载一下以便自己学习,同时和大家分享!
(这篇博客主要是以键盘驱动为例的,不过讲解的是Linux Input Subsystem,可以仔细的研究一下!)
键盘驱动将检 ......
TIMER_INITIALIZER():
1):TIMER_INITIALIZER()用来声明一个定时器,它的定义如下:
#define TIMER_INITIALIZER(_function, _expires, _data) { \
.function = (_fun ......
内核编译完成后会生成zImage内核镜像文件。关于bootloader加载zImage到内核,并且跳转到zImage开始地址运行zImage的过程,相信大家都很容易理解。但对于zImage是如何解压的过程,就不是那么好理解了。本文将结合部分关键代码,讲解zImage的解压过程。
先看看zImage的组成吧。在内核编译完成后会在arch/arm/boot/下生 ......