diff --git a/sched/mqueue/mq_rcvinternal.c b/sched/mqueue/mq_rcvinternal.c index 00ab85e373e..928a839ded7 100644 --- a/sched/mqueue/mq_rcvinternal.c +++ b/sched/mqueue/mq_rcvinternal.c @@ -187,6 +187,11 @@ int nxmq_wait_receive(mqd_t mqdes, FAR struct mqueue_msg_s **rcvmsg) saved_errno = rtcb->pterrno; rtcb->pterrno = OK; + /* Make sure this is not the idle task, descheduling that + * isn't going to end well. + */ + + DEBUGASSERT(NULL != rtcb->flink); up_block_task(rtcb, TSTATE_WAIT_MQNOTEMPTY); /* When we resume at this point, either (1) the message queue diff --git a/sched/mqueue/mq_sndinternal.c b/sched/mqueue/mq_sndinternal.c index af43976b159..072248a6822 100644 --- a/sched/mqueue/mq_sndinternal.c +++ b/sched/mqueue/mq_sndinternal.c @@ -291,6 +291,11 @@ int nxmq_wait_send(mqd_t mqdes) saved_errno = rtcb->pterrno; rtcb->pterrno = OK; + /* Make sure this is not the idle task, descheduling that + * isn't going to end well. + */ + + DEBUGASSERT(NULL != rtcb->flink); up_block_task(rtcb, TSTATE_WAIT_MQNOTFULL); /* When we resume at this point, either (1) the message queue diff --git a/sched/paging/pg_miss.c b/sched/paging/pg_miss.c index 75beda6827b..f8841d46810 100644 --- a/sched/paging/pg_miss.c +++ b/sched/paging/pg_miss.c @@ -142,8 +142,12 @@ void pg_miss(void) * to the next highest priority task. * - The blocked task will be marked with state TSTATE_WAIT_PAGEFILL * and will be retained in the g_waitingforfill prioritized task list. + * + * Need to firstly check that this is not the idle task,descheduling + * that isn't going to end well. */ + DEBUGASSERT(NULL != ftcb->flink); up_block_task(ftcb, TSTATE_WAIT_PAGEFILL); /* Boost the page fill worker thread priority. diff --git a/sched/sched/sched_suspend.c b/sched/sched/sched_suspend.c index eb9c580f581..e38c2cd9f8d 100644 --- a/sched/sched/sched_suspend.c +++ b/sched/sched/sched_suspend.c @@ -95,8 +95,11 @@ void sched_suspend(FAR struct tcb_s *tcb) /* The task was running or runnable before being stopped. Simply * block it in the stopped state. If tcb refers to this task, then * this action will block this task. + * Before doing that make sure this is not the idle task, + * descheduling that isn't going to end well. */ + DEBUGASSERT(NULL != tcb->flink); up_block_task(tcb, TSTATE_TASK_STOPPED); } diff --git a/sched/semaphore/sem_wait.c b/sched/semaphore/sem_wait.c index 96adcdd6f8c..d43fd7bbbfe 100644 --- a/sched/semaphore/sem_wait.c +++ b/sched/semaphore/sem_wait.c @@ -163,8 +163,12 @@ int nxsem_wait(FAR sem_t *sem) saved_errno = rtcb->pterrno; rtcb->pterrno = OK; - /* Add the TCB to the prioritized semaphore wait queue */ + /* Add the TCB to the prioritized semaphore wait queue, after + * checking this is not the idle task - descheduling that + * isn't going to end well. + */ + DEBUGASSERT(NULL != rtcb->flink); up_block_task(rtcb, TSTATE_WAIT_SEM); /* When we resume at this point, either (1) the semaphore has been diff --git a/sched/signal/sig_suspend.c b/sched/signal/sig_suspend.c index a4f5ebdf682..ade7da33b24 100644 --- a/sched/signal/sig_suspend.c +++ b/sched/signal/sig_suspend.c @@ -132,8 +132,12 @@ int sigsuspend(FAR const sigset_t *set) } else { - /* Its time to wait until one of the unblocked signals is posted */ + /* Its time to wait until one of the unblocked signals is posted, + * but first, ensure this is not the idle task, descheduling that + * isn't going to end well. + */ + DEBUGASSERT(NULL != rtcb->flink); up_block_task(rtcb, TSTATE_WAIT_SIG); /* We are running again, restore the original sigprocmask */ diff --git a/sched/signal/sig_timedwait.c b/sched/signal/sig_timedwait.c index cdd6c9536fb..541d7a8aee2 100644 --- a/sched/signal/sig_timedwait.c +++ b/sched/signal/sig_timedwait.c @@ -357,8 +357,12 @@ int nxsig_timedwait(FAR const sigset_t *set, FAR struct siginfo *info, (void)wd_start(rtcb->waitdog, waitticks, (wdentry_t)nxsig_timeout, 1, wdparm.pvarg); - /* Now wait for either the signal or the watchdog */ + /* Now wait for either the signal or the watchdog, but + * first, make sure this is not the idle task, + * descheduling that isn't going to end well. + */ + DEBUGASSERT(NULL != rtcb->flink); up_block_task(rtcb, TSTATE_WAIT_SIG); /* We no longer need the watchdog */ @@ -376,8 +380,12 @@ int nxsig_timedwait(FAR const sigset_t *set, FAR struct siginfo *info, else { - /* And wait until one of the unblocked signals is posted */ + /* And wait until one of the unblocked signals is posted, + * but first make sure this is not the idle task, + * descheduling that isn't going to end well. + */ + DEBUGASSERT(NULL != rtcb->flink); up_block_task(rtcb, TSTATE_WAIT_SIG); }