LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2128|回复: 1

linux.device.drivers

[复制链接]
发表于 2006-9-26 17:00:36 | 显示全部楼层 |阅读模式
linux.device.drivers
=====================

1. modules
        -- insmod, insert a module in kernel, and run the init function which is specified            by
                module_init(<init func>);

        -- rmmod, remove a module from kernel, and run the exit function which is specified                       by
                module_exit(<exit func>);

modules vs applications
        All event-driven applications can be implemented as modules.
        module's exit function must undo everything the init function built up.(i.e. free         resources)
        But application may not always do those all.

        A module, on the other hand, is linked only to the kernel, and the only functions it can call are the ones exported by the kernel;
        an application can call functions it doesn't define, only if it is defined in shared         lib.

2.

printk() is defined in kernel, but it do not support floating-point.
因为module没有lib可用,所以不要include那些常用的head file, i.e. stdarg.h
all head file can be included in module, is include/linux and include/asm

Concurrency in the Kernel
kernel code and driver code must be reentrant(可重入的)

'current' is the global item that can be used in kernel programing.
I.e.
printk(KERN_INFO "The process is \"%s\" (pid %i)\n",

        current->comm, current->pid);

Kernel's stack size is only 4KB.
So if you need larger structures, just get memory by malloc instead of apply great buffer by automatic variables.

obj-m := module.o

module-objs := file1.o file2.o

all system calls has a same prefix: 'sys_'
发表于 2007-4-19 16:00:13 | 显示全部楼层
楼主这篇东西让人意犹未尽啊,好像没讲清楚。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表