mirror of
https://github.com/apache/nuttx.git
synced 2026-06-03 22:20:31 +08:00
sched/sched: Add sched_get_stackinfo()
The new OS interface, sched_get_stackinfo() combines two pthread-specific interfaces into a single generic interface. The existing pthread_get_stackaddr_np() and pthread_get_stacksize_np() are moved from sched/pthread to libs/libc/pthread. There are two motivations for this change: First, it reduces the number of system calls. Secondly, it adds a common hook that is going to used for a future implementation of TLS.
This commit is contained in:
committed by
Abdelatif Guettouche
parent
f03ed73f91
commit
00933cfece
+34
-1
@@ -382,6 +382,21 @@ struct dspace_s
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* struct stackinfo_s ***********************************************************/
|
||||||
|
|
||||||
|
/* Used to report stack information */
|
||||||
|
|
||||||
|
struct stackinfo_s
|
||||||
|
{
|
||||||
|
size_t adj_stack_size; /* Stack size after adjustment */
|
||||||
|
/* for hardware, processor, etc. */
|
||||||
|
/* (for debug purposes only) */
|
||||||
|
FAR void *stack_alloc_ptr; /* Pointer to allocated stack */
|
||||||
|
/* Needed to deallocate stack */
|
||||||
|
FAR void *adj_stack_ptr; /* Adjusted stack_alloc_ptr for HW */
|
||||||
|
/* The initial stack pointer value */
|
||||||
|
};
|
||||||
|
|
||||||
/* struct task_group_s **********************************************************/
|
/* struct task_group_s **********************************************************/
|
||||||
|
|
||||||
/* All threads created by pthread_create belong in the same task group (along
|
/* All threads created by pthread_create belong in the same task group (along
|
||||||
@@ -650,7 +665,7 @@ struct tcb_s
|
|||||||
/* for hardware, processor, etc. */
|
/* for hardware, processor, etc. */
|
||||||
/* (for debug purposes only) */
|
/* (for debug purposes only) */
|
||||||
FAR void *stack_alloc_ptr; /* Pointer to allocated stack */
|
FAR void *stack_alloc_ptr; /* Pointer to allocated stack */
|
||||||
/* Need to deallocate stack */
|
/* Needed to deallocate stack */
|
||||||
FAR void *adj_stack_ptr; /* Adjusted stack_alloc_ptr for HW */
|
FAR void *adj_stack_ptr; /* Adjusted stack_alloc_ptr for HW */
|
||||||
/* The initial stack pointer value */
|
/* The initial stack pointer value */
|
||||||
|
|
||||||
@@ -1223,6 +1238,24 @@ int nxsched_setaffinity(pid_t pid, size_t cpusetsize,
|
|||||||
FAR const cpu_set_t *mask);
|
FAR const cpu_set_t *mask);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/********************************************************************************
|
||||||
|
* Name: sched_get_stackinfo
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Report information about a thread's stack allocation.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* pid_t - Identifies the thread to query. Zero is interpreted as the
|
||||||
|
* the calling thread
|
||||||
|
* stackinfo - User-provided location to return the stack information.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) if successful. Otherwise, a negated errno value is returned.
|
||||||
|
*
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
int sched_get_stackinfo(pid_t pid, FAR struct stackinfo_s *stackinfo);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-20
@@ -66,14 +66,15 @@
|
|||||||
#define SYS_sched_setscheduler (CONFIG_SYS_RESERVED + 10)
|
#define SYS_sched_setscheduler (CONFIG_SYS_RESERVED + 10)
|
||||||
#define SYS_sched_unlock (CONFIG_SYS_RESERVED + 11)
|
#define SYS_sched_unlock (CONFIG_SYS_RESERVED + 11)
|
||||||
#define SYS_sched_yield (CONFIG_SYS_RESERVED + 12)
|
#define SYS_sched_yield (CONFIG_SYS_RESERVED + 12)
|
||||||
|
#define SYS_sched_get_stackinfo (CONFIG_SYS_RESERVED + 13)
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
# define SYS_sched_getaffinity (CONFIG_SYS_RESERVED + 13)
|
# define SYS_sched_getaffinity (CONFIG_SYS_RESERVED + 14)
|
||||||
# define SYS_sched_getcpu (CONFIG_SYS_RESERVED + 14)
|
# define SYS_sched_getcpu (CONFIG_SYS_RESERVED + 15)
|
||||||
# define SYS_sched_setaffinity (CONFIG_SYS_RESERVED + 15)
|
# define SYS_sched_setaffinity (CONFIG_SYS_RESERVED + 16)
|
||||||
# define __SYS_set_errno (CONFIG_SYS_RESERVED + 16)
|
# define __SYS_set_errno (CONFIG_SYS_RESERVED + 17)
|
||||||
#else
|
#else
|
||||||
# define __SYS_set_errno (CONFIG_SYS_RESERVED + 13)
|
# define __SYS_set_errno (CONFIG_SYS_RESERVED + 14)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SYS_set_errno (__SYS_set_errno + 0)
|
#define SYS_set_errno (__SYS_set_errno + 0)
|
||||||
@@ -434,24 +435,22 @@
|
|||||||
# define SYS_pthread_create (__SYS_pthread + 4)
|
# define SYS_pthread_create (__SYS_pthread + 4)
|
||||||
# define SYS_pthread_detach (__SYS_pthread + 5)
|
# define SYS_pthread_detach (__SYS_pthread + 5)
|
||||||
# define SYS_pthread_exit (__SYS_pthread + 6)
|
# define SYS_pthread_exit (__SYS_pthread + 6)
|
||||||
# define SYS_pthread_get_stackaddr_np (__SYS_pthread + 7)
|
# define SYS_pthread_getschedparam (__SYS_pthread + 7)
|
||||||
# define SYS_pthread_get_stacksize_np (__SYS_pthread + 8)
|
# define SYS_pthread_getspecific (__SYS_pthread + 8)
|
||||||
# define SYS_pthread_getschedparam (__SYS_pthread + 9)
|
# define SYS_pthread_join (__SYS_pthread + 9)
|
||||||
# define SYS_pthread_getspecific (__SYS_pthread + 10)
|
# define SYS_pthread_key_create (__SYS_pthread + 10)
|
||||||
# define SYS_pthread_join (__SYS_pthread + 11)
|
# define SYS_pthread_key_delete (__SYS_pthread + 11)
|
||||||
# define SYS_pthread_key_create (__SYS_pthread + 12)
|
# define SYS_pthread_mutex_destroy (__SYS_pthread + 12)
|
||||||
# define SYS_pthread_key_delete (__SYS_pthread + 13)
|
# define SYS_pthread_mutex_init (__SYS_pthread + 13)
|
||||||
# define SYS_pthread_mutex_destroy (__SYS_pthread + 14)
|
# define SYS_pthread_mutex_timedlock (__SYS_pthread + 14)
|
||||||
# define SYS_pthread_mutex_init (__SYS_pthread + 15)
|
# define SYS_pthread_mutex_trylock (__SYS_pthread + 15)
|
||||||
# define SYS_pthread_mutex_timedlock (__SYS_pthread + 16)
|
# define SYS_pthread_mutex_unlock (__SYS_pthread + 16)
|
||||||
# define SYS_pthread_mutex_trylock (__SYS_pthread + 17)
|
|
||||||
# define SYS_pthread_mutex_unlock (__SYS_pthread + 18)
|
|
||||||
|
|
||||||
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
|
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
|
||||||
# define SYS_pthread_mutex_consistent (__SYS_pthread + 19)
|
# define SYS_pthread_mutex_consistent (__SYS_pthread + 17)
|
||||||
# define __SYS_pthread_setschedparam (__SYS_pthread + 20)
|
# define __SYS_pthread_setschedparam (__SYS_pthread + 18)
|
||||||
#else
|
#else
|
||||||
# define __SYS_pthread_setschedparam (__SYS_pthread + 19)
|
# define __SYS_pthread_setschedparam (__SYS_pthread + 17)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# define SYS_pthread_setschedparam (__SYS_pthread_setschedparam + 0)
|
# define SYS_pthread_setschedparam (__SYS_pthread_setschedparam + 0)
|
||||||
|
|||||||
+13
-27
@@ -1,35 +1,20 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# libs/libc/pthread/Make.defs
|
# libs/libc/pthread/Make.defs
|
||||||
#
|
#
|
||||||
# Copyright (C) 2011-2012, 2019 Gregory Nutt. All rights reserved.
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
# 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
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
#
|
#
|
||||||
# 1. Redistributions of source code must retain the above copyright
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# notice, this list of conditions and the following disclaimer.
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# notice, this list of conditions and the following disclaimer in
|
# License for the specific language governing permissions and limitations
|
||||||
# the documentation and/or other materials provided with the
|
# under the License.
|
||||||
# distribution.
|
|
||||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
# used to endorse or promote products derived from this software
|
|
||||||
# without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
@@ -58,6 +43,7 @@ CSRCS += pthread_setcancelstate.c pthread_setcanceltype.c
|
|||||||
CSRCS += pthread_testcancel.c
|
CSRCS += pthread_testcancel.c
|
||||||
CSRCS += pthread_rwlock.c pthread_rwlock_rdlock.c pthread_rwlock_wrlock.c
|
CSRCS += pthread_rwlock.c pthread_rwlock_rdlock.c pthread_rwlock_wrlock.c
|
||||||
CSRCS += pthread_once.c pthread_yield.c
|
CSRCS += pthread_once.c pthread_yield.c
|
||||||
|
CSRCS += pthread_get_stackaddr_np.c pthread_get_stacksize_np.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_SMP),y)
|
ifeq ($(CONFIG_SMP),y)
|
||||||
CSRCS += pthread_attr_getaffinity.c pthread_attr_setaffinity.c
|
CSRCS += pthread_attr_getaffinity.c pthread_attr_setaffinity.c
|
||||||
|
|||||||
+7
-6
@@ -42,7 +42,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#include "pthread/pthread.h"
|
#include "nuttx/sched.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
@@ -63,15 +63,16 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void *pthread_get_stackaddr_np(pthread_t thread)
|
FAR void *pthread_get_stackaddr_np(pthread_t thread)
|
||||||
{
|
{
|
||||||
FAR struct pthread_tcb_s *tcb =
|
struct stackinfo_s stackinfo;
|
||||||
(FAR struct pthread_tcb_s *)sched_gettcb((pid_t)thread);
|
int ret;
|
||||||
|
|
||||||
if (tcb == NULL)
|
ret = sched_get_stackinfo((pid_t)thread, &stackinfo);
|
||||||
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tcb->cmn.adj_stack_ptr;
|
return stackinfo.adj_stack_ptr;
|
||||||
}
|
}
|
||||||
+8
-7
@@ -43,7 +43,7 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "pthread/pthread.h"
|
#include "nuttx/sched.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
* pthread_t - The pthread being queried
|
* pthread_t - The pthread being queried
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* A positive, non-zerp pthread stack address is returned on success. A
|
* A positive, non-zero pthread stack address is returned on success. A
|
||||||
* negative value is returned in the case that the 'thread' argument does
|
* negative value is returned in the case that the 'thread' argument does
|
||||||
* not refer to a valid thread.
|
* not refer to a valid thread.
|
||||||
*
|
*
|
||||||
@@ -67,13 +67,14 @@
|
|||||||
|
|
||||||
ssize_t pthread_get_stacksize_np(pthread_t thread)
|
ssize_t pthread_get_stacksize_np(pthread_t thread)
|
||||||
{
|
{
|
||||||
FAR struct pthread_tcb_s *tcb =
|
struct stackinfo_s stackinfo;
|
||||||
(FAR struct pthread_tcb_s *)sched_gettcb((pid_t)thread);
|
int ret;
|
||||||
|
|
||||||
if (tcb == NULL)
|
ret = sched_get_stackinfo((pid_t)thread, &stackinfo);
|
||||||
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
return -EINVAL;
|
return (ssize_t)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tcb->cmn.adj_stack_size;
|
return stackinfo.adj_stack_size;
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,6 @@ CSRCS += pthread_condtimedwait.c pthread_kill.c pthread_sigmask.c
|
|||||||
CSRCS += pthread_cancel.c
|
CSRCS += pthread_cancel.c
|
||||||
CSRCS += pthread_initialize.c pthread_completejoin.c pthread_findjoininfo.c
|
CSRCS += pthread_initialize.c pthread_completejoin.c pthread_findjoininfo.c
|
||||||
CSRCS += pthread_release.c pthread_setschedprio.c
|
CSRCS += pthread_release.c pthread_setschedprio.c
|
||||||
CSRCS += pthread_get_stackaddr_np.c pthread_get_stacksize_np.c
|
|
||||||
|
|
||||||
ifneq ($(CONFIG_PTHREAD_MUTEX_UNSAFE),y)
|
ifneq ($(CONFIG_PTHREAD_MUTEX_UNSAFE),y)
|
||||||
CSRCS += pthread_mutex.c pthread_mutexconsistent.c pthread_mutexinconsistent.c
|
CSRCS += pthread_mutex.c pthread_mutexconsistent.c pthread_mutexinconsistent.c
|
||||||
|
|||||||
+13
-28
@@ -1,35 +1,20 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# sched/sched/Make.defs
|
# sched/sched/Make.defs
|
||||||
#
|
#
|
||||||
# Copyright (C) 2014, 2018, 2020 Gregory Nutt. All rights reserved.
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
# 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
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
#
|
#
|
||||||
# 1. Redistributions of source code must retain the above copyright
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# notice, this list of conditions and the following disclaimer.
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# notice, this list of conditions and the following disclaimer in
|
# License for the specific language governing permissions and limitations
|
||||||
# the documentation and/or other materials provided with the
|
# under the License.
|
||||||
# distribution.
|
|
||||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
# used to endorse or promote products derived from this software
|
|
||||||
# without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
@@ -43,7 +28,7 @@ CSRCS += sched_setparam.c sched_setpriority.c sched_getparam.c
|
|||||||
CSRCS += sched_setscheduler.c sched_getscheduler.c
|
CSRCS += sched_setscheduler.c sched_getscheduler.c
|
||||||
CSRCS += sched_yield.c sched_rrgetinterval.c sched_foreach.c
|
CSRCS += sched_yield.c sched_rrgetinterval.c sched_foreach.c
|
||||||
CSRCS += sched_lock.c sched_unlock.c sched_lockcount.c
|
CSRCS += sched_lock.c sched_unlock.c sched_lockcount.c
|
||||||
CSRCS += sched_idletask.c sched_self.c
|
CSRCS += sched_idletask.c sched_self.c sched_get_stackinfo.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_PRIORITY_INHERITANCE),y)
|
ifeq ($(CONFIG_PRIORITY_INHERITANCE),y)
|
||||||
CSRCS += sched_reprioritize.c
|
CSRCS += sched_reprioritize.c
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* sched/sched/sched_get_stackinfo.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/config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "nuttx/sched.h"
|
||||||
|
#include "sched/sched.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: sched_get_stackinfo
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Report information about a thread's stack allocation.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* pid_t - Identifies the thread to query. Zero is interpreted as the
|
||||||
|
* the calling thread
|
||||||
|
* stackinfo - User-provided location to return the stack information.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) if successful. Otherwise, a negated errno value is returned.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int sched_get_stackinfo(pid_t pid, FAR struct stackinfo_s *stackinfo)
|
||||||
|
{
|
||||||
|
FAR struct tcb_s *tcb;
|
||||||
|
|
||||||
|
DEBUGASSERT(stackinfo != NULL);
|
||||||
|
|
||||||
|
if (pid == 0)
|
||||||
|
{
|
||||||
|
tcb = this_task();
|
||||||
|
DEBUGASSERT(tcb != NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tcb = sched_gettcb(pid);
|
||||||
|
if (tcb == NULL)
|
||||||
|
{
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stackinfo->adj_stack_size = tcb->adj_stack_size;
|
||||||
|
stackinfo->stack_alloc_ptr = tcb->stack_alloc_ptr;
|
||||||
|
stackinfo->adj_stack_ptr = tcb->adj_stack_ptr;
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
+1
-2
@@ -88,8 +88,6 @@
|
|||||||
"pthread_create","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_t*","FAR const pthread_attr_t*","pthread_startroutine_t","pthread_addr_t"
|
"pthread_create","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_t*","FAR const pthread_attr_t*","pthread_startroutine_t","pthread_addr_t"
|
||||||
"pthread_detach","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_t"
|
"pthread_detach","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_t"
|
||||||
"pthread_exit","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","void","pthread_addr_t"
|
"pthread_exit","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","void","pthread_addr_t"
|
||||||
"pthread_get_stackaddr_np","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","void*","pthread_t"
|
|
||||||
"pthread_get_stacksize_np","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","ssize_t","pthread_t"
|
|
||||||
"pthread_getaffinity_np","pthread.h","!defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SMP)","int","pthread_t","size_t","FAR cpu_set_t*"
|
"pthread_getaffinity_np","pthread.h","!defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SMP)","int","pthread_t","size_t","FAR cpu_set_t*"
|
||||||
"pthread_getschedparam","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_t","FAR int*","FAR struct sched_param*"
|
"pthread_getschedparam","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_t","FAR int*","FAR struct sched_param*"
|
||||||
"pthread_getspecific","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","FAR void*","pthread_key_t"
|
"pthread_getspecific","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","FAR void*","pthread_key_t"
|
||||||
@@ -123,6 +121,7 @@
|
|||||||
"sched_getparam","sched.h","","int","pid_t","struct sched_param*"
|
"sched_getparam","sched.h","","int","pid_t","struct sched_param*"
|
||||||
"sched_getscheduler","sched.h","","int","pid_t"
|
"sched_getscheduler","sched.h","","int","pid_t"
|
||||||
"sched_getstreams","nuttx/sched.h","CONFIG_NFILE_STREAMS > 0","FAR struct streamlist*"
|
"sched_getstreams","nuttx/sched.h","CONFIG_NFILE_STREAMS > 0","FAR struct streamlist*"
|
||||||
|
"sched_get_stackinfo","nuttx/sched.h","","int","pid_t","struct stackinfo_s*"
|
||||||
"sched_lock","sched.h","","int"
|
"sched_lock","sched.h","","int"
|
||||||
"sched_lockcount","sched.h","","int32_t"
|
"sched_lockcount","sched.h","","int32_t"
|
||||||
"sched_rr_get_interval","sched.h","","int","pid_t","struct timespec*"
|
"sched_rr_get_interval","sched.h","","int","pid_t","struct timespec*"
|
||||||
|
|||||||
|
@@ -42,6 +42,7 @@ SYSCALL_LOOKUP(sched_setparam, 2, STUB_sched_setparam)
|
|||||||
SYSCALL_LOOKUP(sched_setscheduler, 3, STUB_sched_setscheduler)
|
SYSCALL_LOOKUP(sched_setscheduler, 3, STUB_sched_setscheduler)
|
||||||
SYSCALL_LOOKUP(sched_unlock, 0, STUB_sched_unlock)
|
SYSCALL_LOOKUP(sched_unlock, 0, STUB_sched_unlock)
|
||||||
SYSCALL_LOOKUP(sched_yield, 0, STUB_sched_yield)
|
SYSCALL_LOOKUP(sched_yield, 0, STUB_sched_yield)
|
||||||
|
SYSCALL_LOOKUP(sched_get_stackinfo, 2, STUB_sched_get_stackinfo)
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
SYSCALL_LOOKUP(sched_getaffinity, 3, STUB_sched_getaffinity)
|
SYSCALL_LOOKUP(sched_getaffinity, 3, STUB_sched_getaffinity)
|
||||||
@@ -304,8 +305,6 @@ SYSCALL_LOOKUP(up_assert, 2, STUB_up_assert)
|
|||||||
SYSCALL_LOOKUP(pthread_create, 4, STUB_pthread_create)
|
SYSCALL_LOOKUP(pthread_create, 4, STUB_pthread_create)
|
||||||
SYSCALL_LOOKUP(pthread_detach, 1, STUB_pthread_detach)
|
SYSCALL_LOOKUP(pthread_detach, 1, STUB_pthread_detach)
|
||||||
SYSCALL_LOOKUP(pthread_exit, 1, STUB_pthread_exit)
|
SYSCALL_LOOKUP(pthread_exit, 1, STUB_pthread_exit)
|
||||||
SYSCALL_LOOKUP(pthread_get_stackaddr_np, 1, STUB_pthread_get_stackaddr_np)
|
|
||||||
SYSCALL_LOOKUP(pthread_get_stacksize_np, 1, STUB_pthread_get_stacksize_np)
|
|
||||||
SYSCALL_LOOKUP(pthread_getschedparam, 3, STUB_pthread_getschedparam)
|
SYSCALL_LOOKUP(pthread_getschedparam, 3, STUB_pthread_getschedparam)
|
||||||
SYSCALL_LOOKUP(pthread_getspecific, 1, STUB_pthread_getspecific)
|
SYSCALL_LOOKUP(pthread_getspecific, 1, STUB_pthread_getspecific)
|
||||||
SYSCALL_LOOKUP(pthread_join, 2, STUB_pthread_join)
|
SYSCALL_LOOKUP(pthread_join, 2, STUB_pthread_join)
|
||||||
|
|||||||
@@ -1,35 +1,20 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* syscall/syscall_stublookup.c
|
* syscall/syscall_stublookup.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011-2013, 2015-2020 Gregory Nutt. All rights reserved.
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* 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
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* notice, this list of conditions and the following disclaimer in
|
* License for the specific language governing permissions and limitations
|
||||||
* the documentation and/or other materials provided with the
|
* under the License.
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@@ -72,6 +57,7 @@ uintptr_t STUB_sched_setscheduler(int nbr, uintptr_t parm1, uintptr_t parm2,
|
|||||||
uintptr_t parm3);
|
uintptr_t parm3);
|
||||||
uintptr_t STUB_sched_unlock(int nbr);
|
uintptr_t STUB_sched_unlock(int nbr);
|
||||||
uintptr_t STUB_sched_yield(int nbr);
|
uintptr_t STUB_sched_yield(int nbr);
|
||||||
|
uintptr_t STUB_sched_get_stackinfo(int nbr, uintptr_t parm1, uintptr_t parm2);
|
||||||
|
|
||||||
uintptr_t STUB_sched_getaffinity(int nbr, uintptr_t parm1, uintptr_t parm2,
|
uintptr_t STUB_sched_getaffinity(int nbr, uintptr_t parm1, uintptr_t parm2,
|
||||||
uintptr_t parm3);
|
uintptr_t parm3);
|
||||||
@@ -325,8 +311,6 @@ uintptr_t STUB_pthread_join(int nbr, uintptr_t parm1, uintptr_t parm2);
|
|||||||
uintptr_t STUB_pthread_key_create(int nbr, uintptr_t parm1,
|
uintptr_t STUB_pthread_key_create(int nbr, uintptr_t parm1,
|
||||||
uintptr_t parm2);
|
uintptr_t parm2);
|
||||||
uintptr_t STUB_pthread_key_delete(int nbr, uintptr_t parm1);
|
uintptr_t STUB_pthread_key_delete(int nbr, uintptr_t parm1);
|
||||||
uintptr_t STUB_pthread_get_stackaddr_np(int nbr, uintptr_t parm1);
|
|
||||||
uintptr_t STUB_pthread_get_stacksize_np(int nbr, uintptr_t parm1);
|
|
||||||
uintptr_t STUB_pthread_mutex_destroy(int nbr, uintptr_t parm1);
|
uintptr_t STUB_pthread_mutex_destroy(int nbr, uintptr_t parm1);
|
||||||
uintptr_t STUB_pthread_mutex_init(int nbr, uintptr_t parm1,
|
uintptr_t STUB_pthread_mutex_init(int nbr, uintptr_t parm1,
|
||||||
uintptr_t parm2);
|
uintptr_t parm2);
|
||||||
|
|||||||
Reference in New Issue
Block a user