免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1197 | 回复: 0
打印 上一主题 下一主题

solaris device driver 2 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-05-14 15:26 |只看该作者 |倒序浏览
"writing device driver" study.

1. Multithreading
1) storage classes
- Automatic(stack) data. Every thread has private stack. No need for the driver to lock automatic data.
- Global static data. can be shared by any number of threads in the driver. should be locked at times.
- Kernel heap data. Any number of threads in the driver can share kernel heap data, such as data allocated by kmem_alloc(9F). The driver needs to protect shared data at all times.

2) locks
a) Mutual-extension locks(Mutex). Mutexes provide a way to allow only one thread at a time access to that data.
b) reader/writer locks. Many threads can hold the lock simultaneously for reading, but only one thread can hold the lock for writing.
c) Semaphores.

3) Thread Synchronization
a) Condition variables. The usual use of condition variables is to check a condition (for  example, device state, data structure reference count,etc.) while holding a mutex which keeps other  threads  from changing  the  condition. The cv_wait(9F) function releases the mutex before blocking the thread and reacquires the mutex before returning.




本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/38597/showart_301076.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP