mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 21:36:28 +08:00
Rename cpuset_t to cpu_set_t which is the type used in some non-standard Linux/GNU interfaces. Move definitions of cpu_set_t to include/sys/types.h. Add prototypes for sched_setaffinity(), sched_getaffinity(), pthread_attr_setaffinity_np(), pthread_attr_getaffinity_np(), pthread_setaffinity_np(), and pthread_getaffinity_np(). No implementation is yet in place.
This commit is contained in:
@@ -11498,4 +11498,10 @@
|
|||||||
other way too, but this is more compliant with POSIX (2016-02-18).
|
other way too, but this is more compliant with POSIX (2016-02-18).
|
||||||
* fs/ procfs/fs_procfsproc.c: Add support for showing CPU if SMP is
|
* fs/ procfs/fs_procfsproc.c: Add support for showing CPU if SMP is
|
||||||
is enabled (2016-02-19).
|
is enabled (2016-02-19).
|
||||||
|
* include/pthread.h, sched.h, sys/types.h and other files: Rename
|
||||||
|
cpuset_t to cpu_set_t which is the type used in some non-standard
|
||||||
|
Linux/GNU interfaces. Move definitions of cpu_set_t to include/sys/types.h.
|
||||||
|
Add prototypes for sched_setaffinity(), sched_getaffinity(),
|
||||||
|
pthread_attr_setaffinity_np(), pthread_attr_getaffinity_np(),
|
||||||
|
pthread_setaffinity_np(), and pthread_getaffinity_np(). No implementation
|
||||||
|
is yet in place (2016-02-19).
|
||||||
|
|||||||
+1
-1
Submodule configs updated: d5a1be277d...82e43f4b00
@@ -41,6 +41,8 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sys/type.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef CONFIG_SPINLOCK
|
#ifdef CONFIG_SPINLOCK
|
||||||
@@ -73,18 +75,6 @@ struct spinlock_s
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This is the smallest integer type that will not a bitset of all CPUs */
|
|
||||||
|
|
||||||
#if (CONFIG_SMP_NCPUS <= 8)
|
|
||||||
typedef volatile uint8_t cpuset_t;
|
|
||||||
#elif (CONFIG_SMP_NCPUS <= 16)
|
|
||||||
typedef volatile uint16_t cpuset_t;
|
|
||||||
#elif (CONFIG_SMP_NCPUS <= 32)
|
|
||||||
typedef volatile uint32_t cpuset_t;
|
|
||||||
#else
|
|
||||||
# error SMP: Extensions needed to support this number of CPUs
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -286,7 +276,7 @@ void spin_unlockr(FAR struct spinlock_s *lock);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void spin_setbit(FAR volatile cpuset_t *set, unsigned int cpu,
|
void spin_setbit(FAR volatile cpu_set_t *set, unsigned int cpu,
|
||||||
FAR volatile spinlock_t *setlock,
|
FAR volatile spinlock_t *setlock,
|
||||||
FAR volatile spinlock_t *orlock);
|
FAR volatile spinlock_t *orlock);
|
||||||
|
|
||||||
@@ -307,7 +297,7 @@ void spin_setbit(FAR volatile cpuset_t *set, unsigned int cpu,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void spin_clrbit(FAR volatile cpuset_t *set, unsigned int cpu,
|
void spin_clrbit(FAR volatile cpu_set_t *set, unsigned int cpu,
|
||||||
FAR volatile spinlock_t *setlock,
|
FAR volatile spinlock_t *setlock,
|
||||||
FAR volatile spinlock_t *orlock);
|
FAR volatile spinlock_t *orlock);
|
||||||
|
|
||||||
|
|||||||
@@ -290,6 +290,16 @@ int pthread_attr_setinheritsched(FAR pthread_attr_t *attr,
|
|||||||
int pthread_attr_getinheritsched(FAR const pthread_attr_t *attr,
|
int pthread_attr_getinheritsched(FAR const pthread_attr_t *attr,
|
||||||
FAR int *inheritsched);
|
FAR int *inheritsched);
|
||||||
|
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
/* Set or obtain thread affinity attributes */
|
||||||
|
|
||||||
|
int pthread_attr_setaffinity_np(FAR pthread_attr_t *attr,
|
||||||
|
size_t cpusetsize,
|
||||||
|
FAR const cpu_set_t *cpuset);
|
||||||
|
int pthread_attr_getaffinity_np(FAR const pthread_attr_t *attr,
|
||||||
|
size_t cpusetsize, cpu_set_t *cpuset);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Set or obtain the default stack size */
|
/* Set or obtain the default stack size */
|
||||||
|
|
||||||
int pthread_attr_setstacksize(FAR pthread_attr_t *attr, long stacksize);
|
int pthread_attr_setstacksize(FAR pthread_attr_t *attr, long stacksize);
|
||||||
@@ -346,6 +356,15 @@ int pthread_setschedparam(pthread_t thread, int policy,
|
|||||||
FAR const struct sched_param *param);
|
FAR const struct sched_param *param);
|
||||||
int pthread_setschedprio(pthread_t thread, int prio);
|
int pthread_setschedprio(pthread_t thread, int prio);
|
||||||
|
|
||||||
|
/* Thread affinity */
|
||||||
|
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize,
|
||||||
|
FAR const cpu_set_t *cpuset);
|
||||||
|
int pthread_getaffinity_np(pthread_t thread, size_t cpusetsize,
|
||||||
|
FAR cpu_set_t *cpuset);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Thread-specific Data Interfaces */
|
/* Thread-specific Data Interfaces */
|
||||||
|
|
||||||
int pthread_key_create(FAR pthread_key_t *key,
|
int pthread_key_create(FAR pthread_key_t *key,
|
||||||
|
|||||||
@@ -131,6 +131,14 @@ int sched_get_priority_max(int policy);
|
|||||||
int sched_get_priority_min(int policy);
|
int sched_get_priority_min(int policy);
|
||||||
int sched_rr_get_interval(pid_t pid, FAR struct timespec *interval);
|
int sched_rr_get_interval(pid_t pid, FAR struct timespec *interval);
|
||||||
|
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
/* Task affinity */
|
||||||
|
|
||||||
|
int sched_setaffinity(pid_t pid, size_t cpusetsize,
|
||||||
|
FAR const cpu_set_t *mask);
|
||||||
|
int sched_getaffinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Task Switching Interfaces (non-standard) */
|
/* Task Switching Interfaces (non-standard) */
|
||||||
|
|
||||||
int sched_lock(void);
|
int sched_lock(void);
|
||||||
|
|||||||
+3
-1
@@ -43,6 +43,8 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <nuttx/compiler.h>
|
#include <nuttx/compiler.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/spinlock.h>
|
#include <nuttx/spinlock.h>
|
||||||
@@ -68,7 +70,7 @@ extern volatile spinlock_t g_cpu_irqlock;
|
|||||||
/* Used to keep track of which CPU(s) hold the IRQ lock. */
|
/* Used to keep track of which CPU(s) hold the IRQ lock. */
|
||||||
|
|
||||||
extern volatile spinlock_t g_cpu_irqsetlock;
|
extern volatile spinlock_t g_cpu_irqsetlock;
|
||||||
extern volatile cpuset_t g_cpu_irqset;
|
extern volatile cpu_set_t g_cpu_irqset;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -39,6 +39,8 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <nuttx/spinlock.h>
|
#include <nuttx/spinlock.h>
|
||||||
#include <arch/irq.h>
|
#include <arch/irq.h>
|
||||||
|
|
||||||
@@ -59,7 +61,7 @@ volatile spinlock_t g_cpu_irqlock = SP_UNLOCKED;
|
|||||||
/* Used to keep track of which CPU(s) hold the IRQ lock. */
|
/* Used to keep track of which CPU(s) hold the IRQ lock. */
|
||||||
|
|
||||||
volatile spinlock_t g_cpu_irqsetlock;
|
volatile spinlock_t g_cpu_irqsetlock;
|
||||||
volatile cpuset_t g_cpu_irqset;
|
volatile cpu_set_t g_cpu_irqset;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
|
|||||||
+1
-1
@@ -358,7 +358,7 @@ extern volatile spinlock_t g_cpu_schedlock;
|
|||||||
/* Used to keep track of which CPU(s) hold the IRQ lock. */
|
/* Used to keep track of which CPU(s) hold the IRQ lock. */
|
||||||
|
|
||||||
extern volatile spinlock_t g_cpu_locksetlock;
|
extern volatile spinlock_t g_cpu_locksetlock;
|
||||||
extern volatile cpuset_t g_cpu_lockset;
|
extern volatile cpu_set_t g_cpu_lockset;
|
||||||
|
|
||||||
#endif /* CONFIG_SMP */
|
#endif /* CONFIG_SMP */
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
@@ -111,7 +112,7 @@ volatile spinlock_t g_cpu_schedlock = SP_UNLOCKED;
|
|||||||
/* Used to keep track of which CPU(s) hold the IRQ lock. */
|
/* Used to keep track of which CPU(s) hold the IRQ lock. */
|
||||||
|
|
||||||
volatile spinlock_t g_cpu_locksetlock;
|
volatile spinlock_t g_cpu_locksetlock;
|
||||||
volatile cpuset_t g_cpu_lockset;
|
volatile cpu_set_t g_cpu_lockset;
|
||||||
|
|
||||||
#endif /* CONFIG_SMP */
|
#endif /* CONFIG_SMP */
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
@@ -312,7 +313,7 @@ void spin_unlockr(FAR struct spinlock_s *lock)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void spin_setbit(FAR volatile cpuset_t *set, unsigned int cpu,
|
void spin_setbit(FAR volatile cpu_set_t *set, unsigned int cpu,
|
||||||
FAR volatile spinlock_t *setlock,
|
FAR volatile spinlock_t *setlock,
|
||||||
FAR volatile spinlock_t *orlock)
|
FAR volatile spinlock_t *orlock)
|
||||||
{
|
{
|
||||||
@@ -347,7 +348,7 @@ void spin_setbit(FAR volatile cpuset_t *set, unsigned int cpu,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void spin_clrbit(FAR volatile cpuset_t *set, unsigned int cpu,
|
void spin_clrbit(FAR volatile cpu_set_t *set, unsigned int cpu,
|
||||||
FAR volatile spinlock_t *setlock,
|
FAR volatile spinlock_t *setlock,
|
||||||
FAR volatile spinlock_t *orlock)
|
FAR volatile spinlock_t *orlock)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user