2015-10-03 01:43:18 +02:00
|
|
|
/****************************************************************************
|
2021-03-08 22:39:04 +01:00
|
|
|
* sched/mqueue/mq_recover.c
|
2013-02-05 20:50:37 +01:00
|
|
|
*
|
2024-09-11 13:45:11 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2020-03-10 16:26:30 +01: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-05 20:50:37 +01:00
|
|
|
*
|
2020-03-10 16:26:30 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2013-02-05 20:50:37 +01:00
|
|
|
*
|
2020-03-10 16:26:30 +01: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-05 20:50:37 +01:00
|
|
|
*
|
2015-10-03 01:43:18 +02:00
|
|
|
****************************************************************************/
|
2013-02-05 20:50:37 +01:00
|
|
|
|
2015-10-03 01:43:18 +02:00
|
|
|
/****************************************************************************
|
2013-02-05 20:50:37 +01:00
|
|
|
* Included Files
|
2015-10-03 01:43:18 +02:00
|
|
|
****************************************************************************/
|
2013-02-05 20:50:37 +01:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include <nuttx/mqueue.h>
|
|
|
|
#include <nuttx/sched.h>
|
|
|
|
|
2014-08-08 20:31:23 +02:00
|
|
|
#include "mqueue/mqueue.h"
|
2013-02-05 20:50:37 +01:00
|
|
|
|
2015-10-03 01:43:18 +02:00
|
|
|
/****************************************************************************
|
2013-02-05 20:50:37 +01:00
|
|
|
* Public Functions
|
2015-10-03 01:43:18 +02:00
|
|
|
****************************************************************************/
|
2013-02-05 20:50:37 +01:00
|
|
|
|
2015-10-03 01:43:18 +02:00
|
|
|
/****************************************************************************
|
2017-10-09 17:06:46 +02:00
|
|
|
* Name: nxmq_recover
|
2013-02-05 20:50:37 +01: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-01 17:00:02 +01:00
|
|
|
* Input Parameters:
|
2013-02-05 20:50:37 +01:00
|
|
|
* tcb - The TCB of the terminated task or thread
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2013-02-05 20:50:37 +01:00
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function is called from task deletion logic in a safe context.
|
|
|
|
*
|
2015-10-03 01:43:18 +02:00
|
|
|
****************************************************************************/
|
2013-02-05 20:50:37 +01:00
|
|
|
|
2017-10-09 17:06:46 +02:00
|
|
|
void nxmq_recover(FAR struct tcb_s *tcb)
|
2013-02-05 20:50:37 +01:00
|
|
|
{
|
2022-09-22 04:31:40 +02:00
|
|
|
FAR struct mqueue_inode_s *msgq;
|
|
|
|
|
2013-02-06 16:43:28 +01: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-04 20:42:51 +01:00
|
|
|
* timer was canceled and deleted in nxtask_recover() before this
|
2013-02-06 16:43:28 +01:00
|
|
|
* function was called.
|
2013-02-05 20:50:37 +01:00
|
|
|
*/
|
2014-04-13 22:32:20 +02:00
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
/* Was the task waiting for a message queue to become non-empty? */
|
|
|
|
|
2022-09-22 04:31:40 +02:00
|
|
|
msgq = tcb->waitobj;
|
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
if (tcb->task_state == TSTATE_WAIT_MQNOTEMPTY)
|
|
|
|
{
|
|
|
|
/* Decrement the count of waiters */
|
|
|
|
|
2022-10-17 09:49:16 +02:00
|
|
|
DEBUGASSERT(msgq && msgq->cmn.nwaitnotempty > 0);
|
|
|
|
msgq->cmn.nwaitnotempty--;
|
2013-02-05 20:50:37 +01: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-10-17 09:49:16 +02:00
|
|
|
DEBUGASSERT(msgq && msgq->cmn.nwaitnotfull > 0);
|
|
|
|
msgq->cmn.nwaitnotfull--;
|
2013-02-05 20:50:37 +01:00
|
|
|
}
|
|
|
|
}
|