Linux device driver
Xlong_Du
这个作者很懒,什么都没留下…
展开
-
mutex和semaphore的区别
mutex是一个二进制标志,确保在代码关键区(critical section)互相排斥 semaphore的计数可以超过1,用于保护多重同类资源,N=1的semaphore称为Binary semaphore 一般情况下mutex和Binary semaphore是没有区别的,而在某些系统中会有差异,表现在: mutex一定要由获得锁的进程来释放,而semaphore可以由其他进程来释放,故semaphore可以用于进程间同步 建议mutex用于保护critical section,原创 2011-04-02 10:19:00 · 555 阅读 · 0 评论 -
基础驱动相关的3个重要内核数据结构 -from ldd3
file_operation struct file inode file_operetion: file_operation 结构是一个字符驱动如何建立这个连接struct module *owner 第一个 file_operations 成员根本不是一个操作; 它是一个指向拥有这个结构的模块的指针. 这个成员用来在它的操作还在被使用时阻止模块被卸载. 几乎所有时间中, 它被简单初始化为THIS_MODULE, 一个在 中定义的宏.loff_t (*l原创 2011-04-02 10:38:00 · 416 阅读 · 0 评论 -
Implementation of linux semaphore - from ldd3
<br />semaphore : <asm/semaphore.h><br /> <br />create a semaphore:<br /> void sema_init(strct semaphore *sem, int val); //val: the initial value of semaphore<br /> <br />semaphore is usually used as mutex mode, so it can be defined and initialize原创 2011-04-02 10:59:00 · 324 阅读 · 0 评论 -
Using semaphore in scull - from ldd3
struct scull_dev { struct scull_qset *data; /* Pointer to first quantum set */ int quantum; /* the current quantum size */ int qset; /* the current array size */ unsigned long size; /* amount of data stored here */ unsigned in原创 2011-04-02 11:16:00 · 299 阅读 · 0 评论