Completion,完成量,用于多线程间同步,即线程A要往下执行需要等待线程B执行到指定代码后才继续执行,这时就可以使用该机制,用于一个线程告诉另一个线程指定工作已完成。 在Linux Kernel源码include/linux/completion.h文件里有相关的结构体和接口函数的定义和声明,从结构体可以看到其是基于等待队列机制实现的,该机制后期再了解,下面是completion相关内容:
struct completion {
unsigned int done;
wait_queue_head_t wait;
};
static inline void init_completion(struct completion *x) ;
static inline void reinit_completion(struct completion *x);
extern void wait_for_completion(struct completion *);
extern int wait_for_completion_interruptible(struct completion *x);
extern int wait_for_completion_killable(struct completion *x);
extern unsigned long wait_for_completion_timeout(struct complet