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
@ -35,10 +35,10 @@
|
|||||||
#include <nuttx/lib/lib.h>
|
#include <nuttx/lib/lib.h>
|
||||||
#include <nuttx/semaphore.h>
|
#include <nuttx/semaphore.h>
|
||||||
#include <nuttx/sched.h>
|
#include <nuttx/sched.h>
|
||||||
#include <nuttx/tls.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
#include "group/group.h"
|
#include "group/group.h"
|
||||||
|
#include "tls/tls.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
@ -185,9 +185,8 @@ int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype)
|
|||||||
|
|
||||||
/* Alloc task info for group */
|
/* Alloc task info for group */
|
||||||
|
|
||||||
group->tg_info = (FAR struct task_info_s *)
|
ret = task_init_info(group);
|
||||||
group_zalloc(group, sizeof(struct task_info_s));
|
if (ret < 0)
|
||||||
if (!group->tg_info)
|
|
||||||
{
|
{
|
||||||
goto errout_with_member;
|
goto errout_with_member;
|
||||||
}
|
}
|
||||||
@ -200,10 +199,6 @@ int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype)
|
|||||||
|
|
||||||
group_inherit_identity(group);
|
group_inherit_identity(group);
|
||||||
|
|
||||||
/* Initial user space semaphore */
|
|
||||||
|
|
||||||
nxsem_init(&group->tg_info->ta_sem, 0, 1);
|
|
||||||
|
|
||||||
/* Initialize file descriptors for the TCB */
|
/* Initialize file descriptors for the TCB */
|
||||||
|
|
||||||
files_initlist(&group->tg_filelist);
|
files_initlist(&group->tg_filelist);
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include "pthread/pthread.h"
|
#include "pthread/pthread.h"
|
||||||
#include "mqueue/mqueue.h"
|
#include "mqueue/mqueue.h"
|
||||||
#include "group/group.h"
|
#include "group/group.h"
|
||||||
|
#include "tls/tls.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
@ -137,8 +138,7 @@ static inline void group_release(FAR struct task_group_s *group)
|
|||||||
task_tls_destruct();
|
task_tls_destruct();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nxsem_destroy(&group->tg_info->ta_sem);
|
task_uninit_info(group);
|
||||||
group_free(group, group->tg_info);
|
|
||||||
|
|
||||||
#if defined(CONFIG_SCHED_HAVE_PARENT) && defined(CONFIG_SCHED_CHILD_STATUS)
|
#if defined(CONFIG_SCHED_HAVE_PARENT) && defined(CONFIG_SCHED_CHILD_STATUS)
|
||||||
/* Free all un-reaped child exit 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
|
# 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
|
* 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
|
* Name: tls_init_info
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user