2015-10-03 01:43:18 +02:00
|
|
|
/****************************************************************************
|
2014-08-08 22:21:48 +02:00
|
|
|
* sched/pthread/pthread_release.c
|
2013-02-03 18:39:54 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +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-03 18:39:54 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2013-02-03 18:39:54 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +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-03 18:39:54 +01:00
|
|
|
*
|
2015-10-03 01:43:18 +02:00
|
|
|
****************************************************************************/
|
2013-02-03 18:39:54 +01:00
|
|
|
|
2015-10-03 01:43:18 +02:00
|
|
|
/****************************************************************************
|
2013-02-03 18:39:54 +01:00
|
|
|
* Included Files
|
2015-10-03 01:43:18 +02:00
|
|
|
****************************************************************************/
|
2013-02-03 18:39:54 +01:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sched.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
2014-08-09 02:39:28 +02:00
|
|
|
#include <nuttx/kmalloc.h>
|
|
|
|
|
2014-08-08 20:55:02 +02:00
|
|
|
#include "pthread/pthread.h"
|
2013-02-03 18:39:54 +01:00
|
|
|
|
2015-10-03 01:43:18 +02:00
|
|
|
/****************************************************************************
|
2013-02-03 18:39:54 +01:00
|
|
|
* Public Functions
|
2015-10-03 01:43:18 +02:00
|
|
|
****************************************************************************/
|
2013-02-03 18:39:54 +01:00
|
|
|
|
2015-10-03 01:43:18 +02:00
|
|
|
/****************************************************************************
|
2013-02-03 18:39:54 +01:00
|
|
|
* Name: pthread_release
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Release pthread resources from the task group with the group
|
|
|
|
* terminated.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2013-02-03 18:39:54 +01:00
|
|
|
* group = The task group containing the pthread resources to be
|
|
|
|
* released.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2013-02-03 18:39:54 +01:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
*
|
|
|
|
* POSIX Compatibility:
|
|
|
|
*
|
2015-10-03 01:43:18 +02:00
|
|
|
****************************************************************************/
|
2013-02-03 18:39:54 +01:00
|
|
|
|
|
|
|
void pthread_release(FAR struct task_group_s *group)
|
|
|
|
{
|
|
|
|
FAR struct join_s *join;
|
2014-08-27 22:22:00 +02:00
|
|
|
DEBUGASSERT(group);
|
2013-02-03 18:39:54 +01:00
|
|
|
|
|
|
|
/* Visit and delete each join structure still in the list. Since we
|
|
|
|
* are last exiting thread of the group, no special protection should
|
|
|
|
* be required.
|
|
|
|
*/
|
|
|
|
|
|
|
|
while (group->tg_joinhead)
|
|
|
|
{
|
|
|
|
/* Remove the join from the head of the list. */
|
|
|
|
|
|
|
|
join = group->tg_joinhead;
|
|
|
|
group->tg_joinhead = join->next;
|
|
|
|
|
|
|
|
/* Destroy the join semaphores */
|
|
|
|
|
2020-01-02 17:49:34 +01:00
|
|
|
nxsem_destroy(&join->data_sem);
|
|
|
|
nxsem_destroy(&join->exit_sem);
|
2013-02-03 18:39:54 +01:00
|
|
|
|
|
|
|
/* And deallocate the join structure */
|
|
|
|
|
2020-04-07 16:31:47 +02:00
|
|
|
kmm_free(join);
|
2013-02-03 18:39:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Destroy the join list semaphore */
|
|
|
|
|
2020-01-02 17:49:34 +01:00
|
|
|
nxsem_destroy(&group->tg_joinsem);
|
2013-02-03 18:39:54 +01:00
|
|
|
}
|