sched/sched/sched_getcpu.c: Implement non-standard interface.

If SMP is enabled this function will return the number of the CPU that the thread is running on.  This is non-standard but follows GLIBC if __GNU_SOURCE is enabled.  The returned CPU number is, however, worthless since it returns the CPU number of the CPU that was executing the task when the function was called.  The application can never know the true CPU number of the CPU tht it is running on since that value is volatile and change change at any time.
This commit is contained in:
Gregory Nutt
2020-01-31 20:25:15 +00:00
committed by Ouss4
parent 80277d1630
commit 2def8035db
7 changed files with 108 additions and 13 deletions
+1
View File
@@ -119,6 +119,7 @@
"rewinddir","dirent.h","","void","FAR DIR*"
"rmdir","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char*"
"rmmod","nuttx/module.h","defined(CONFIG_MODULE)","int","FAR void *"
"sched_getcpu","sched.h","defined(CONFIG_SMP)","int"
"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*"
1 _exit unistd.h void int
119 rewinddir dirent.h void FAR DIR*
120 rmdir unistd.h !defined(CONFIG_DISABLE_MOUNTPOINT) int FAR const char*
121 rmmod nuttx/module.h defined(CONFIG_MODULE) int FAR void *
122 sched_getcpu sched.h defined(CONFIG_SMP) int
123 sched_getparam sched.h int pid_t
124 sched_getscheduler sched.h int pid_t
125 sched_getstreams nuttx/sched.h CONFIG_NFILE_STREAMS > 0 FAR struct streamlist*
+6 -1
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* syscall/syscall_lookup.h
*
* Copyright (C) 2011, 2013-2019 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2013-2019, 2020 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -47,6 +47,7 @@ SYSCALL_LOOKUP1(_exit, 1, STUB__exit)
SYSCALL_LOOKUP(exit, 1, STUB_exit)
SYSCALL_LOOKUP(get_errno, 0, STUB_get_errno)
SYSCALL_LOOKUP(getpid, 0, STUB_getpid)
SYSCALL_LOOKUP(sched_getparam, 2, STUB_sched_getparam)
SYSCALL_LOOKUP(sched_getscheduler, 1, STUB_sched_getscheduler)
SYSCALL_LOOKUP(sched_lock, 0, STUB_sched_lock)
@@ -56,6 +57,10 @@ 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)
#ifdef CONFIG_SMP
SYSCALL_LOOKUP(sched_getcpu, 0, STUB_sched_getcpu)
#endif
SYSCALL_LOOKUP(set_errno, 1, STUB_set_errno)
SYSCALL_LOOKUP(uname, 1, STUB_uname)
+4 -5
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* syscall/syscall_stublookup.c
*
* Copyright (C) 2011-2013, 2015-2019 Gregory Nutt. All rights reserved.
* Copyright (C) 2011-2013, 2015-2020 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -48,10 +48,6 @@
#if defined(CONFIG_LIB_SYSCALL)
/****************************************************************************
* Pre-processor definitions
****************************************************************************/
/****************************************************************************
* Stub Function Prototypes
****************************************************************************/
@@ -64,6 +60,7 @@ uintptr_t STUB__exit(int nbr, uintptr_t parm1);
uintptr_t STUB_exit(int nbr, uintptr_t parm1);
uintptr_t STUB_get_errno(int nbr);
uintptr_t STUB_getpid(int nbr);
uintptr_t STUB_sched_getparam(int nbr, uintptr_t parm1, uintptr_t parm2);
uintptr_t STUB_sched_getscheduler(int nbr, uintptr_t parm1);
uintptr_t STUB_sched_lock(int nbr);
@@ -75,6 +72,8 @@ 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_getcpu(int nbr);
uintptr_t STUB_set_errno(int nbr, uintptr_t parm1);
uintptr_t STUB_uname(int nbr, uintptr_t parm1);