From 83dca09e1c31637583b99823c86ed86fa3e12491 Mon Sep 17 00:00:00 2001 From: tangyuxin <462747508@qq.com> Date: Sat, 6 Feb 2021 21:54:25 +0800 Subject: [PATCH] =?UTF-8?q?[workqueue]=20=E4=BF=AE=E5=A4=8D=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E5=B7=A5=E4=BD=9C=E5=90=8E=E7=AB=8B=E5=8D=B3=E5=8F=96?= =?UTF-8?q?=E6=B6=88=EF=BC=8C=E8=8E=B7=E5=8F=96=E6=97=A0=E6=95=88=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E4=BB=BB=E5=8A=A1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当高优先级任务提交工作后,立即取消。此时队列被唤醒,下面紧接着获取链表中第一个任务。但此时已经是空链表了。 每次线程被唤醒。检查当前任务链表是否未空 --- components/drivers/src/workqueue.c | 6 +++--- 1 file 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);