From 40366f415397df96e6c66b1178494d0fa6ca75fd Mon Sep 17 00:00:00 2001 From: zhangyuan21 Date: Thu, 22 Sep 2022 10:32:09 +0800 Subject: [PATCH] sched: clear waitsem and msgwaitq after remove blocked --- sched/mqueue/mq_rcvinternal.c | 1 - sched/mqueue/mq_sndinternal.c | 1 - sched/mqueue/mq_waitirq.c | 2 -- sched/sched/sched_removeblocked.c | 4 ++++ sched/semaphore/sem_post.c | 4 ---- sched/semaphore/sem_waitirq.c | 4 ---- 6 files changed, 4 insertions(+), 12 deletions(-) diff --git a/sched/mqueue/mq_rcvinternal.c b/sched/mqueue/mq_rcvinternal.c index 9d5c642c39..c704576af7 100644 --- a/sched/mqueue/mq_rcvinternal.c +++ b/sched/mqueue/mq_rcvinternal.c @@ -303,7 +303,6 @@ ssize_t nxmq_do_receive(FAR struct mqueue_inode_s *msgq, wd_cancel(&btcb->waitdog); } - btcb->waitobj = NULL; msgq->nwaitnotfull--; up_unblock_task(btcb); } diff --git a/sched/mqueue/mq_sndinternal.c b/sched/mqueue/mq_sndinternal.c index c924ba7df4..af1e3eb44d 100644 --- a/sched/mqueue/mq_sndinternal.c +++ b/sched/mqueue/mq_sndinternal.c @@ -410,7 +410,6 @@ int nxmq_do_send(FAR struct mqueue_inode_s *msgq, wd_cancel(&btcb->waitdog); } - btcb->waitobj = NULL; msgq->nwaitnotempty--; up_unblock_task(btcb); } diff --git a/sched/mqueue/mq_waitirq.c b/sched/mqueue/mq_waitirq.c index a9c9767cb6..5ec36c2bac 100644 --- a/sched/mqueue/mq_waitirq.c +++ b/sched/mqueue/mq_waitirq.c @@ -83,8 +83,6 @@ void nxmq_wait_irq(FAR struct tcb_s *wtcb, int errcode) msgq = wtcb->waitobj; DEBUGASSERT(msgq); - wtcb->waitobj = NULL; - /* Decrement the count of waiters and cancel the wait */ if (wtcb->task_state == TSTATE_WAIT_MQNOTEMPTY) diff --git a/sched/sched/sched_removeblocked.c b/sched/sched/sched_removeblocked.c index 83d184e4fb..b5f479b227 100644 --- a/sched/sched/sched_removeblocked.c +++ b/sched/sched/sched_removeblocked.c @@ -67,6 +67,10 @@ void nxsched_remove_blocked(FAR struct tcb_s *btcb) dq_rem((FAR dq_entry_t *)btcb, TLIST_BLOCKED(task_state)); + /* Indicate that the wait is over. */ + + btcb->waitobj = NULL; + /* Make sure the TCB's state corresponds to not being in * any list */ diff --git a/sched/semaphore/sem_post.c b/sched/semaphore/sem_post.c index 20f42a4103..917238355a 100644 --- a/sched/semaphore/sem_post.c +++ b/sched/semaphore/sem_post.c @@ -155,10 +155,6 @@ int nxsem_post(FAR sem_t *sem) wd_cancel(&stcb->waitdog); - /* It is, let the task take the semaphore */ - - stcb->waitobj = NULL; - /* Restart the waiting task. */ up_unblock_task(stcb); diff --git a/sched/semaphore/sem_waitirq.c b/sched/semaphore/sem_waitirq.c index 89f977afd1..2a296ca166 100644 --- a/sched/semaphore/sem_waitirq.c +++ b/sched/semaphore/sem_waitirq.c @@ -97,10 +97,6 @@ void nxsem_wait_irq(FAR struct tcb_s *wtcb, int errcode) sem->semcount++; - /* Indicate that the semaphore wait is over. */ - - wtcb->waitobj = NULL; - /* Mark the errno value for the thread. */ wtcb->errcode = errcode;