linux内核之等待队列

等待队列还是弄的不太明白,线有点乱……

把知道的记录下吧。wait_queue确实是双向链表。有一个表头,加后面的链表体,就像火车头拖着后面的车厢。不同的是这个车头还跟最后一节车厢连在一起形成一个闭环。这就是双向链表了。

结构如下

/*
 * A single wait-queue entry structure:
 */
struct wait_queue_entry {
	unsigned int		flags;
	void			*private;//指向task_struct,就是进程pcb了
	wait_queue_func_t	func;
	struct list_head	entry;//双向链表
};

struct wait_queue_head {
	spinlock_t		lock;
	struct list_head	head;
};
typedef struct wait_queue_head wait_queue_head_t;

struct task_struct;

其中,struct list_head如下

struct list_head {
	struct list_head *next, *prev;
};

双向链表无疑了。之前没有看list_head的结构,还觉得网上的博客都说错了……

copy一张图,很清晰

图来自这篇文章https://blog.51cto.com/weiguozhihui/1566704,其中对队列的操作写的很清楚了,然而我还是不知道把进程加入队列后,它怎么去休眠的,是主动schedule()然后醒来后检查条件一直循环还是调用其他东西进入休眠?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值