2015-10-03 07:43:18 +08:00
|
|
|
/****************************************************************************
|
2021-03-09 05:39:04 +08:00
|
|
|
* sched/mqueue/mq_recover.c
|
2013-02-06 03:50:37 +08:00
|
|
|
*
|
2020-03-10 23:26:30 +08:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2013-02-06 03:50:37 +08:00
|
|
|
*
|
2020-03-10 23:26:30 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2013-02-06 03:50:37 +08:00
|
|
|
*
|
2020-03-10 23:26:30 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2013-02-06 03:50:37 +08:00
|
|
|
*
|
2015-10-03 07:43:18 +08:00
|
|
|
****************************************************************************/
|
2013-02-06 03:50:37 +08:00
|
|
|
|
2015-10-03 07:43:18 +08:00
|
|
|
/****************************************************************************
|
2013-02-06 03:50:37 +08:00
|
|
|
* Included Files
|
2015-10-03 07:43:18 +08:00
|
|
|
****************************************************************************/
|
2013-02-06 03:50:37 +08:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include <nuttx/mqueue.h>
|
|
|
|
#include <nuttx/sched.h>
|
|
|
|
|
2014-08-09 02:31:23 +08:00
|
|
|
#include "mqueue/mqueue.h"
|
2013-02-06 03:50:37 +08:00
|
|
|
|
2015-10-03 07:43:18 +08:00
|
|
|
/****************************************************************************
|
2013-02-06 03:50:37 +08:00
|
|
|
* Public Functions
|
2015-10-03 07:43:18 +08:00
|
|
|
****************************************************************************/
|
2013-02-06 03:50:37 +08:00
|
|
|
|
2015-10-03 07:43:18 +08:00
|
|
|
/****************************************************************************
|
2017-10-09 23:06:46 +08:00
|
|
|
* Name: nxmq_recover
|
2013-02-06 03:50:37 +08:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function is called when a task is deleted via task_deleted or
|
|
|
|
* via pthread_cancel. I checks if the task was waiting for a message
|
|
|
|
* queue event and adjusts counts appropriately.
|
|
|
|
*
|
2018-02-02 00:00:02 +08:00
|
|
|
* Input Parameters:
|
2013-02-06 03:50:37 +08:00
|
|
|
* tcb - The TCB of the terminated task or thread
|
|
|
|
*
|
2018-02-02 00:00:02 +08:00
|
|
|
* Returned Value:
|
2013-02-06 03:50:37 +08:00
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function is called from task deletion logic in a safe context.
|
|
|
|
*
|
2015-10-03 07:43:18 +08:00
|
|
|
****************************************************************************/
|
2013-02-06 03:50:37 +08:00
|
|
|
|
2017-10-09 23:06:46 +08:00
|
|
|
void nxmq_recover(FAR struct tcb_s *tcb)
|
2013-02-06 03:50:37 +08:00
|
|
|
{
|
2022-09-22 10:31:40 +08:00
|
|
|
FAR struct mqueue_inode_s *msgq;
|
|
|
|
|
2013-02-06 23:43:28 +08:00
|
|
|
/* If were were waiting for a timed message queue event, then the
|
This commit renames all internal OS functions defined under sched/task so that they begin with the prefix. For example, nxtask_exit() vs. task_exit().
Squashed commit of the following:
Trivial, cosmetic
sched/, arch/, and include: Rename task_vforkstart() as nxtask_vforkstart()
sched/, arch/, and include: Rename task_vforkabort() as nxtask_vforkabort()
sched/, arch/, and include: Rename task_vforksetup() as nxtask_vfork_setup()
sched/: Rename notify_cancellation() as nxnotify_cancellation()
sched/: Rename task_recover() to nxtask_recover()
sched/task, sched/pthread/, Documentation/: Rename task_argsetup() and task_terminate() to nxtask_argsetup() and nxtask_terminate(), respectively.
sched/task: Rename task_schedsetup() to nxtask_schedsetup()
sched/ (plus some binfmt/, include/, and arch/): Rename task_start() and task_starthook() to nxtask_start() and nxtask_starthook().
arch/ and sched/: Rename task_exit() and task_exithook() to nxtask_exit() and nxtask_exithook(), respectively.
sched/task: Rename all internal, static, functions to begin with the nx prefix.
2019-02-05 03:42:51 +08:00
|
|
|
* timer was canceled and deleted in nxtask_recover() before this
|
2013-02-06 23:43:28 +08:00
|
|
|
* function was called.
|
2013-02-06 03:50:37 +08:00
|
|
|
*/
|
2014-04-14 04:32:20 +08:00
|
|
|
|
2013-02-06 03:50:37 +08:00
|
|
|
/* Was the task waiting for a message queue to become non-empty? */
|
|
|
|
|
2022-09-22 10:31:40 +08:00
|
|
|
msgq = tcb->waitobj;
|
|
|
|
|
2013-02-06 03:50:37 +08:00
|
|
|
if (tcb->task_state == TSTATE_WAIT_MQNOTEMPTY)
|
|
|
|
{
|
|
|
|
/* Decrement the count of waiters */
|
|
|
|
|
2022-09-22 10:31:40 +08:00
|
|
|
DEBUGASSERT(msgq && msgq->nwaitnotempty > 0);
|
|
|
|
msgq->nwaitnotempty--;
|
2013-02-06 03:50:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Was the task waiting for a message queue to become non-full? */
|
|
|
|
|
|
|
|
else if (tcb->task_state == TSTATE_WAIT_MQNOTFULL)
|
|
|
|
{
|
|
|
|
/* Decrement the count of waiters */
|
|
|
|
|
2022-09-22 10:31:40 +08:00
|
|
|
DEBUGASSERT(msgq && msgq->nwaitnotfull > 0);
|
|
|
|
msgq->nwaitnotfull--;
|
2013-02-06 03:50:37 +08:00
|
|
|
}
|
|
|
|
}
|