sched/: Add debug assertions before each call to up_block_task() to assure that there is no attempt to block an IDLE task.

This commit is contained in:
Gregory Nutt 2018-11-30 06:54:15 -06:00
parent af96756995
commit 3b22d13493
7 changed files with 37 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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);
}

View File

@ -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

View File

@ -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 */

View File

@ -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);
}