* See also: complete(), wait_for_completion() (and friends _timeout, * _interruptible, _interruptible_timeout, and _killable), init_completion(), * reinit_completion(), and macros DECLARE_COMPLETION(), * DECLARE_COMPLETION_ONSTACK(). */ struct completion { unsigned int done; wait_queue_...
wait_for_completion(&mycompletion); wait_for_completion_interruptible(&mycompletion); wait_for_completion_timeout(&mycompletion,timeout); 三者区别: wait_for_completion是不可中断的(non-interruptible),这意味着无论是否收到中断信号,当前线程都会一直等待完成量的完成。此外,该函数也没有超时功能,即使等待时...
再次强调一下:特别是在使用一些等待API变体具有更复杂结果时,比如超时或信号(_timeout()、_killable()和_interruptible())变体,等待可能会在对象仍然被另一个线程使用时提前完成,而从wait_on_completion*()调用函数返回将会释放函数堆栈,并且如果在其他线程中执行了complete(),将会导致微妙的数据损坏。简单的测试可能...
2.3.1wait_for_completion wait_for_completion用于等待完成量的释放,定义在kernel/sched/completion.c; do_wait_for_common(structcompletion *x,long(*action)(long),longtimeout,intstate) {if(!x->done) { DECLARE_WAITQUEUE(wait, current); __add_wait_queue_entry_tail_exclusive(&x->wait, &wait);...
wait_for_completion_*_timeout() can return: 0: if the wait timed out -ve: if the wait was interrupted +ve: if the completion was completed. As they currently return an 'unsigned long', the last two cases are not easily distinguished which can easily result in buggy code, as is the...
wait_for_completion最终由下面函数实现: 代码语言:javascript 复制 staticinline long __scheddo_wait_for_common(struct completion*x,long timeout,int state){if(!x->done){DECLARE_WAITQUEUE(wait,current);wait.flags|=WQ_FLAG_EXCLUSIVE;__add_wait_queue_tail(&x->wait,&wait);do{if(signal_pending_...
static inline void init_completion(struct completion *x) { x->done = 0; init_waitqueue_head(&x->wait); } 要等待completion,可进行如下调用: void wait_for_completion(struct completion *c); 触发completion事件,调用: void complete(struct completion *c); //唤醒一个等待线程 ...
static inline void init_completion(struct completion *x) { x->done = 0; init_waitqueue_head(&x->wait); } 要等待completion,可进行如下调用: void wait_for_completion(struct completion *c); 触发completion事件,调用: void complete(struct completion *c); //唤醒一个等待线程 ...
wait_for_completion最终由下面函数实现: staticinline long __scheddo_wait_for_common(struct completion*x,long timeout,int state){if(!x->done){DECLARE_WAITQUEUE(wait,current);wait.flags|=WQ_FLAG_EXCLUSIVE;__add_wait_queue_tail(&x->wait,&wait);do{if(signal_pending_state(state,current)){ti...
MQTTClient_publishMessage(client, TOPIC, &pubmsg, &token);printf("Waiting for up to %d seconds for publication of %s\n""on topic %s for client with ClientID: %s\n", (int)(TIMEOUT/1000), message, TOPIC, CLIENTID); rc = MQTTClient_waitForCompletion(client, token, TIMEOUT);printf("Me...