完成量
定义:
#include<linux/completion>
struct completion {
unsigned int done;
wait_queue_head_t wait;
};
根据定义可以知道完成量其原理和等待队列有关。
常用函数定义在kernel/sched/completion.c
#define init_completion(x) __init_completion(x)
void wait_for_completion(struct completion *);
void complete(struct completion *);
void complete_all(struct completion *);
大体上常用的就是以上几个,当然还有其它很多变种的函数,具体的可以查看源代码。
使用场景:
例程:
参考:
1:https://eathanq.github.io/2020/12/09/waitq/
2:https://www.cnblogs.com/zyly/p/17810463.html
3:https://deepinout.com/linux-kernel-api/linux-kernel-api-process-scheduling/linux-kernel-api-complete_all.html
4:https://blog.youkuaiyun.com/fybon/article/details/64922855