diff options
| author | tangyuxin <[email protected]> | 2021-02-06 21:54:25 +0800 |
|---|---|---|
| committer | tangyuxin <[email protected]> | 2021-02-06 21:54:25 +0800 |
| commit | 83dca09e1c31637583b99823c86ed86fa3e12491 (patch) | |
| tree | 83b5b907aec7ab4797bcc64572b700403d599ce3 /components/drivers | |
| parent | 7eabe5c9e9a2a93aa7303bee15c156e623986194 (diff) | |
[workqueue] 修复提交工作后立即取消,获取无效工作任务的问题
当高优先级任务提交工作后,立即取消。此时队列被唤醒,下面紧接着获取链表中第一个任务。但此时已经是空链表了。
每次线程被唤醒。检查当前任务链表是否未空
Diffstat (limited to 'components/drivers')
| -rw-r--r-- | components/drivers/src/workqueue.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/components/drivers/src/workqueue.c b/components/drivers/src/workqueue.c index 3feeaea0be..ce1ca071c3 100644 --- a/components/drivers/src/workqueue.c +++ b/components/drivers/src/workqueue.c @@ -58,15 +58,17 @@ static void _workqueue_thread_entry(void *parameter) while (1) { + level = rt_hw_interrupt_disable(); if (rt_list_isempty(&(queue->work_list))) { + rt_hw_interrupt_enable(level); /* no software timer exist, suspend self. */ rt_thread_suspend(rt_thread_self()); rt_schedule(); + continue; } /* we have work to do with. */ - level = rt_hw_interrupt_disable(); work = rt_list_entry(queue->work_list.next, struct rt_work, list); rt_list_remove(&(work->list)); queue->work_current = work; @@ -76,10 +78,8 @@ static void _workqueue_thread_entry(void *parameter) /* do work */ work->work_func(work, work->work_data); - level = rt_hw_interrupt_disable(); /* clean current work */ queue->work_current = RT_NULL; - rt_hw_interrupt_enable(level); /* ack work completion */ _workqueue_work_completion(queue); |
