mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 08:38:38 +08:00
sched/tls: Add task_init_info and task_uninit_info
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
47b707bbf8
commit
01c8bebf58
6 changed files with 162 additions and 11 deletions
|
@ -35,10 +35,10 @@
|
|||
#include <nuttx/lib/lib.h>
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/sched.h>
|
||||
#include <nuttx/tls.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "group/group.h"
|
||||
#include "tls/tls.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
|
@ -185,9 +185,8 @@ int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype)
|
|||
|
||||
/* Alloc task info for group */
|
||||
|
||||
group->tg_info = (FAR struct task_info_s *)
|
||||
group_zalloc(group, sizeof(struct task_info_s));
|
||||
if (!group->tg_info)
|
||||
ret = task_init_info(group);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout_with_member;
|
||||
}
|
||||
|
@ -200,10 +199,6 @@ int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype)
|
|||
|
||||
group_inherit_identity(group);
|
||||
|
||||
/* Initial user space semaphore */
|
||||
|
||||
nxsem_init(&group->tg_info->ta_sem, 0, 1);
|
||||
|
||||
/* Initialize file descriptors for the TCB */
|
||||
|
||||
files_initlist(&group->tg_filelist);
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "pthread/pthread.h"
|
||||
#include "mqueue/mqueue.h"
|
||||
#include "group/group.h"
|
||||
#include "tls/tls.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
|
@ -137,8 +138,7 @@ static inline void group_release(FAR struct task_group_s *group)
|
|||
task_tls_destruct();
|
||||
#endif
|
||||
|
||||
nxsem_destroy(&group->tg_info->ta_sem);
|
||||
group_free(group, group->tg_info);
|
||||
task_uninit_info(group);
|
||||
|
||||
#if defined(CONFIG_SCHED_HAVE_PARENT) && defined(CONFIG_SCHED_CHILD_STATUS)
|
||||
/* Free all un-reaped child exit status */
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#
|
||||
############################################################################
|
||||
|
||||
CSRCS += tls_initinfo.c tls_dupinfo.c
|
||||
CSRCS += task_initinfo.c task_uninitinfo.c tls_initinfo.c tls_dupinfo.c
|
||||
|
||||
# Include tls build support
|
||||
|
||||
|
|
69
sched/tls/task_initinfo.c
Normal file
69
sched/tls/task_initinfo.c
Normal file
|
@ -0,0 +1,69 @@
|
|||
/****************************************************************************
|
||||
* sched/tls/task_initinfo.c
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/tls.h>
|
||||
|
||||
#include "tls.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: task_init_info
|
||||
*
|
||||
* Description:
|
||||
* Allocate and initilize task_info_s structure.
|
||||
*
|
||||
* Input Parameters:
|
||||
* - group: The group of new task
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int task_init_info(FAR struct task_group_s *group)
|
||||
{
|
||||
FAR struct task_info_s *info;
|
||||
|
||||
/* Allocate task info for group */
|
||||
|
||||
info = group_zalloc(group, sizeof(struct task_info_s));
|
||||
if (info == NULL)
|
||||
{
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Initialize user space semaphore */
|
||||
|
||||
nxsem_init(&info->ta_sem, 0, 1);
|
||||
group->tg_info = info;
|
||||
|
||||
return OK;
|
||||
}
|
55
sched/tls/task_uninitinfo.c
Normal file
55
sched/tls/task_uninitinfo.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/****************************************************************************
|
||||
* sched/tls/task_uninitinfo.c
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/tls.h>
|
||||
|
||||
#include "tls.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: task_uninit_info
|
||||
*
|
||||
* Description:
|
||||
* Uninitilize and free task_info_s structure.
|
||||
*
|
||||
* Input Parameters:
|
||||
* - group: The group of new task
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void task_uninit_info(FAR struct task_group_s *group)
|
||||
{
|
||||
FAR struct task_info_s *info = group->tg_info;
|
||||
|
||||
nxsem_destroy(&info->ta_sem);
|
||||
group_free(group, info);
|
||||
}
|
|
@ -31,6 +31,38 @@
|
|||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: task_init_info
|
||||
*
|
||||
* Description:
|
||||
* Allocate and initilize task_info_s structure.
|
||||
*
|
||||
* Input Parameters:
|
||||
* - group: The group of new task
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int task_init_info(FAR struct task_group_s *group);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: task_uninit_info
|
||||
*
|
||||
* Description:
|
||||
* Uninitilize and free task_info_s structure.
|
||||
*
|
||||
* Input Parameters:
|
||||
* - group: The group of new task
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void task_uninit_info(FAR struct task_group_s *group);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tls_init_info
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue