kernel 什么时候可以中断 什么时候不可以中断

unbutun 2010-02-04 03:05:25
比如 wait_event_interruptible 和wait_for_completion 两者区别是一个可以中断,另一个不可以中断,那什么时候要可以被中断,什么时候要不可以被中断呢?



谢谢大家了。
...全文
166 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
unbutun 2010-05-02
  • 打赏
  • 举报
回复
up



up
joyself 2010-02-04
  • 打赏
  • 举报
回复
Interruptible and Uninterruptible Sleep

A process can sleep in two different modes, interruptible and uninterruptible. In an interruptible sleep, the process could be woken up for processing of signals. In an uninterruptible sleep, the process could not be woken up other than by issuing an explicit wake_up. Interruptible sleep is the preferred way of sleeping, unless there is a situation in which signals cannot be handled at all, such as device I/O.

http://www.linuxjournal.com/article/8144
olla168 2010-02-04
  • 打赏
  • 举报
回复
这里的中断可等同于打断,不同于计算机专业词"中断"
olla168 2010-02-04
  • 打赏
  • 举报
回复
wait_event(queue, condition)/*不可中断休眠,不推荐*/
wait_event_interruptible(queue, condition)/*推荐,返回非零值意味着休眠被中断,且驱动应返回 -ERESTARTSYS*/
wait_event_interruptible_timeout(queue, condition, timeout) /*有限的时间的休眠;若超时,则不管条件为何值返回0,*/

void wait_for_completion(struct completion *c);/* 等待completion */
joyself 2010-02-04
  • 打赏
  • 举报
回复
如楼上说的,楼主的两个函数类似。
lijinfenghust 2010-02-04
  • 打赏
  • 举报
回复
楼主貌似对中断理解错了。

中断在本质上说是任何时刻都会发生的。比如按一下键盘,移动一下鼠标。

wait_event_inerruptible本意是说在等事件的时候 ,如果发生中断,那么立即就从这个函数返回,同时返回值是-E_RESTARTSYS.这个时候系统调用收到这个错误消息的时候,一般会重头重新开始调用驱动的服务代码。这样保证了驱动的服务可以被“事务性”的处理。

而后面那个是说一旦在等事件的时候,即使有外设中断了,中断也不会被响应了。

不过这2个函数我没深入理解过。
反正 down_interruptable() 是这样的。
天亮后说晚安 2010-02-04
  • 打赏
  • 举报
回复
帮顶。。。。学习中

4,468

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧