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:
Gregory Nutt
2020-05-03 14:16:36 -06:00
committed by Abdelatif Guettouche
parent f03ed73f91
commit 00933cfece
11 changed files with 186 additions and 123 deletions
+1 -2
View File
@@ -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_detach","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_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_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"
@@ -123,6 +121,7 @@
"sched_getparam","sched.h","","int","pid_t","struct sched_param*"
"sched_getscheduler","sched.h","","int","pid_t"
"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_lockcount","sched.h","","int32_t"
"sched_rr_get_interval","sched.h","","int","pid_t","struct timespec*"
1 _exit unistd.h void int
88 pthread_create pthread.h !defined(CONFIG_DISABLE_PTHREAD) int FAR pthread_t*
89 pthread_detach pthread.h !defined(CONFIG_DISABLE_PTHREAD) int pthread_t
90 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
91 pthread_getaffinity_np pthread.h !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SMP) int pthread_t
92 pthread_getschedparam pthread.h !defined(CONFIG_DISABLE_PTHREAD) int pthread_t
93 pthread_getspecific pthread.h !defined(CONFIG_DISABLE_PTHREAD) FAR void* pthread_key_t
121 sched_getparam sched.h int pid_t
122 sched_getscheduler sched.h int pid_t
123 sched_getstreams nuttx/sched.h CONFIG_NFILE_STREAMS > 0 FAR struct streamlist*
124 sched_get_stackinfo nuttx/sched.h int pid_t
125 sched_lock sched.h int
126 sched_lockcount sched.h int32_t
127 sched_rr_get_interval sched.h int pid_t
+1 -2
View File
@@ -42,6 +42,7 @@ SYSCALL_LOOKUP(sched_setparam, 2, STUB_sched_setparam)
SYSCALL_LOOKUP(sched_setscheduler, 3, STUB_sched_setscheduler)
SYSCALL_LOOKUP(sched_unlock, 0, STUB_sched_unlock)
SYSCALL_LOOKUP(sched_yield, 0, STUB_sched_yield)
SYSCALL_LOOKUP(sched_get_stackinfo, 2, STUB_sched_get_stackinfo)
#ifdef CONFIG_SMP
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_detach, 1, STUB_pthread_detach)
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_getspecific, 1, STUB_pthread_getspecific)
SYSCALL_LOOKUP(pthread_join, 2, STUB_pthread_join)
+13 -29
View File
@@ -1,35 +1,20 @@
/****************************************************************************
* syscall/syscall_stublookup.c
*
* Copyright (C) 2011-2013, 2015-2020 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* 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
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* http://www.apache.org/licenses/LICENSE-2.0
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* 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.
* 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.
*
****************************************************************************/
@@ -72,6 +57,7 @@ uintptr_t STUB_sched_setscheduler(int nbr, uintptr_t parm1, uintptr_t parm2,
uintptr_t parm3);
uintptr_t STUB_sched_unlock(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 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 parm2);
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_init(int nbr, uintptr_t parm1,
uintptr_t parm2);