mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 01:05:54 +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
|
||||
|
||||
/* 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 **********************************************************/
|
||||
|
||||
/* 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 debug purposes only) */
|
||||
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 */
|
||||
/* The initial stack pointer value */
|
||||
|
||||
@@ -1223,6 +1238,24 @@ int nxsched_setaffinity(pid_t pid, size_t cpusetsize,
|
||||
FAR const cpu_set_t *mask);
|
||||
#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
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
+19
-20
@@ -66,14 +66,15 @@
|
||||
#define SYS_sched_setscheduler (CONFIG_SYS_RESERVED + 10)
|
||||
#define SYS_sched_unlock (CONFIG_SYS_RESERVED + 11)
|
||||
#define SYS_sched_yield (CONFIG_SYS_RESERVED + 12)
|
||||
#define SYS_sched_get_stackinfo (CONFIG_SYS_RESERVED + 13)
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
# define SYS_sched_getaffinity (CONFIG_SYS_RESERVED + 13)
|
||||
# define SYS_sched_getcpu (CONFIG_SYS_RESERVED + 14)
|
||||
# define SYS_sched_setaffinity (CONFIG_SYS_RESERVED + 15)
|
||||
# define __SYS_set_errno (CONFIG_SYS_RESERVED + 16)
|
||||
# define SYS_sched_getaffinity (CONFIG_SYS_RESERVED + 14)
|
||||
# define SYS_sched_getcpu (CONFIG_SYS_RESERVED + 15)
|
||||
# define SYS_sched_setaffinity (CONFIG_SYS_RESERVED + 16)
|
||||
# define __SYS_set_errno (CONFIG_SYS_RESERVED + 17)
|
||||
#else
|
||||
# define __SYS_set_errno (CONFIG_SYS_RESERVED + 13)
|
||||
# define __SYS_set_errno (CONFIG_SYS_RESERVED + 14)
|
||||
#endif
|
||||
|
||||
#define SYS_set_errno (__SYS_set_errno + 0)
|
||||
@@ -434,24 +435,22 @@
|
||||
# define SYS_pthread_create (__SYS_pthread + 4)
|
||||
# define SYS_pthread_detach (__SYS_pthread + 5)
|
||||
# define SYS_pthread_exit (__SYS_pthread + 6)
|
||||
# define SYS_pthread_get_stackaddr_np (__SYS_pthread + 7)
|
||||
# define SYS_pthread_get_stacksize_np (__SYS_pthread + 8)
|
||||
# define SYS_pthread_getschedparam (__SYS_pthread + 9)
|
||||
# define SYS_pthread_getspecific (__SYS_pthread + 10)
|
||||
# define SYS_pthread_join (__SYS_pthread + 11)
|
||||
# define SYS_pthread_key_create (__SYS_pthread + 12)
|
||||
# define SYS_pthread_key_delete (__SYS_pthread + 13)
|
||||
# define SYS_pthread_mutex_destroy (__SYS_pthread + 14)
|
||||
# define SYS_pthread_mutex_init (__SYS_pthread + 15)
|
||||
# define SYS_pthread_mutex_timedlock (__SYS_pthread + 16)
|
||||
# define SYS_pthread_mutex_trylock (__SYS_pthread + 17)
|
||||
# define SYS_pthread_mutex_unlock (__SYS_pthread + 18)
|
||||
# define SYS_pthread_getschedparam (__SYS_pthread + 7)
|
||||
# define SYS_pthread_getspecific (__SYS_pthread + 8)
|
||||
# define SYS_pthread_join (__SYS_pthread + 9)
|
||||
# define SYS_pthread_key_create (__SYS_pthread + 10)
|
||||
# define SYS_pthread_key_delete (__SYS_pthread + 11)
|
||||
# define SYS_pthread_mutex_destroy (__SYS_pthread + 12)
|
||||
# define SYS_pthread_mutex_init (__SYS_pthread + 13)
|
||||
# define SYS_pthread_mutex_timedlock (__SYS_pthread + 14)
|
||||
# define SYS_pthread_mutex_trylock (__SYS_pthread + 15)
|
||||
# define SYS_pthread_mutex_unlock (__SYS_pthread + 16)
|
||||
|
||||
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
|
||||
# define SYS_pthread_mutex_consistent (__SYS_pthread + 19)
|
||||
# define __SYS_pthread_setschedparam (__SYS_pthread + 20)
|
||||
# define SYS_pthread_mutex_consistent (__SYS_pthread + 17)
|
||||
# define __SYS_pthread_setschedparam (__SYS_pthread + 18)
|
||||
#else
|
||||
# define __SYS_pthread_setschedparam (__SYS_pthread + 19)
|
||||
# define __SYS_pthread_setschedparam (__SYS_pthread + 17)
|
||||
#endif
|
||||
|
||||
# define SYS_pthread_setschedparam (__SYS_pthread_setschedparam + 0)
|
||||
|
||||
Reference in New Issue
Block a user