内核中随处可见的等待队列详解2
来源:互联网 发布:windows查看tcp连接数 编辑:程序博客网 时间:2024/05/01 12:42
(2)wait_event_interruptible()函数:
和wait_event()的区别是调用该宏在等待的过程中当前进程会被设置为TASK_INTERRUPTIBLE状态.在每次被唤醒的时候,首先检查condition是否为真,如果为真则返回,否则检查如果进程是被信号唤醒,会返回-ERESTARTSYS错误码.如果是condition为真,则返回0.
(3)wait_event_timeout()宏:
也与wait_event()类似.不过如果所给的睡眠时间为负数则立即返回.如果在睡眠期间被唤醒,且condition为真则返回剩余的睡眠时间,否则继续睡眠直到到达或超过给定的睡眠时间,然后返回0.
(4)wait_event_interruptible_timeout()宏:
与wait_event_timeout()类似,不过如果在睡眠期间被信号打断则返回ERESTARTSYS错误码.
(5) wait_event_interruptible_exclusive()宏
同样和wait_event_interruptible()一样,不过该睡眠的进程是一个互斥进程.
5、唤醒队列:
(1)wake_up()函数:
#define wake_up(x) __wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 1, NULL)
void fastcall __wake_up(wait_queue_head_t *q, unsigned int mode,
int nr_exclusive, void *key)
{
unsigned long flags;
spin_lock_irqsave(&q->lock, flags);
__wake_up_common(q, mode, nr_exclusive, 0, key);
spin_unlock_irqrestore(&q->lock, flags);
}
static void __wake_up_common(wait_queue_head_t *q, unsigned int mode,
int nr_exclusive, int sync, void *key)
{
struct list_head *tmp, *next;
list_for_each_safe(tmp, next, &q->task_list) {
wait_queue_t *curr = list_entry(tmp, wait_queue_t, task_list);
unsigned flags = curr->flags;
if (curr->func(curr, mode, sync, key) &&
(flags & WQ_FLAG_EXCLUSIVE) && !--nr_exclusive)
break;
}
}
唤醒等待队列.可唤醒处于TASK_INTERRUPTIBLE和TASK_UNINTERUPTIBLE状态的进程,和wait_event/wait_event_timeout成对使用.
(2)wake_up_interruptible()函数:
和wake_up()唯一的区别是它只能唤醒TASK_INTERRUPTIBLE状态的进程.,与wait_event_interruptible/wait_event_interruptible_timeout/ wait_event_interruptible_exclusive成对使用.
(3)
#define wake_up_all(x) __wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 0, NULL)
#define wake_up_interruptible_nr(x, nr) __wake_up(x, TASK_INTERRUPTIBLE, nr, NULL)
#define wake_up_interruptible_all(x) __wake_up(x, TASK_INTERRUPTIBLE, 0, NULL)
这些也基本都和wake_up/wake_up_interruptible一样
转自http://341719xubin.blog.163.com/blog/static/132920793201161931653947/
- 内核中随处可见的等待队列详解2
- 内核中随处可见的等待队列详解(转)
- 内核中随处可见的等待队列详解1
- 内核中随处可见的等待队列详解3
- 内核的等待队列
- Linux内核的等待队列
- Linux内核的等待队列
- 内核等待队列的学习
- Linux内核的等待队列
- Linux内核的等待队列
- Linux内核的等待队列
- Linux内核的等待队列
- Linux内核等待队列的使用方法总结
- Linux内核的等待队列(转载)
- Linux内核的等待队列[转]
- Linux内核 - 等待队列的使用
- 转载_Linux内核的等待队列
- linux内核等待队列的使用
- QQ聊天记录备份BAK文件的修复方法
- xcode4.2 ARC错误处理
- 交互式图形图像软件
- 转 Python3中文教程
- DLNA的介绍
- 内核中随处可见的等待队列详解2
- 内核中随处可见的等待队列详解3
- 【搜索】核反应
- 数据结构&算法实践—【排序|选择排序】选择排序
- Find–atime –ctime –mtime的用法与区别总结
- emacs中用gdb调试
- 【转载】FI中 BSEG簇表 和BSIS、BSAS、BSID、BSAD、BSIK、BSAK六个表的关系
- 博客开通
- 扣费软件的运转机制与原理解析