a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 97|回复: 0

[综合辅导] Linux辅导:解读linux驱动同步与互斥

[复制链接]
发表于 2012-8-4 12:07:07 | 显示全部楼层 |阅读模式
事件等待队列一般用于linux驱动的异步通信,也可以叫做申请设备使用权等待队列。当多个进程去操作一个设备时,这个时候一般要用到事件队列。   1、不可中断睡眠:0 g) z% W6 w, [5 @- C% Z" z
  wait_event(queue, condition)
9 p+ w3 e$ X. P+ T8 O  wait_event_interruptible(queue, condition)- z8 o% T) v& e. @/ [2 w' P
  两个函数只有在condition变为true才能唤醒,否则一直睡眠,即是调用wake_up()也不能唤醒。
. k5 @" l+ J7 r7 f  2、可中断睡眠
. R* b. J% o# P  wait_event_timeout(queue, condition, timeout)
# l6 `$ ], B5 h( e2 z  e0 l  wait_event_interruptible_timeout(queue, condition, timeout)
8 R- _: i/ f! [9 `* g( v- k+ j/ P  两个函数在condition变为true或wake_up_interruptible()被调用都能被唤醒。: v* R- J! D* C; T& x
  3,唤醒函数:( z% B1 e" `. X3 ?
  void wake_up(wait_queue_head_t *queue);  //唤醒所有. s1 K, i4 k: g/ q! g4 Z. s, I; L
  void wake_up_interruptible(wait_queue_head_t *queue); //唤醒interruptible
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-5-21 12:35 , Processed in 0.155974 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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