mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
sched/pthread: set default pthread name to parent's name
Align ps behavior with linux:
linux:
$ ps -e -T | grep hello
3758130 3758130 pts/10 00:00:00 hello
3758130 3758131 pts/10 00:00:00 hello
nuttx:
nsh> ps
PID GROUP PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK COMMAND
...
4 4 100 FIFO Task --- Waiting Signal 00000000 067504 hello
5 4 100 FIFO pthread --- Waiting Signal 00000000 067536 hello 0x561cef0dfc53 0x1
Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
committed by
Petro Karashchenko
parent
0443889124
commit
2ad0a02182
@@ -58,16 +58,6 @@
|
|||||||
|
|
||||||
const pthread_attr_t g_default_pthread_attr = PTHREAD_ATTR_INITIALIZER;
|
const pthread_attr_t g_default_pthread_attr = PTHREAD_ATTR_INITIALIZER;
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
/* This is the name for name-less pthreads */
|
|
||||||
|
|
||||||
static const char g_pthreadname[] = "<pthread>";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -95,13 +85,14 @@ static const char g_pthreadname[] = "<pthread>";
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static inline void pthread_tcb_setup(FAR struct pthread_tcb_s *ptcb,
|
static inline void pthread_tcb_setup(FAR struct pthread_tcb_s *ptcb,
|
||||||
|
FAR struct tcb_s *parent,
|
||||||
pthread_trampoline_t trampoline,
|
pthread_trampoline_t trampoline,
|
||||||
pthread_addr_t arg)
|
pthread_addr_t arg)
|
||||||
{
|
{
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
#if CONFIG_TASK_NAME_SIZE > 0
|
||||||
/* Copy the pthread name into the TCB */
|
/* Copy the pthread name into the TCB */
|
||||||
|
|
||||||
strncpy(ptcb->cmn.name, g_pthreadname, CONFIG_TASK_NAME_SIZE);
|
strncpy(ptcb->cmn.name, parent->name, CONFIG_TASK_NAME_SIZE);
|
||||||
ptcb->cmn.name[CONFIG_TASK_NAME_SIZE] = '\0';
|
ptcb->cmn.name[CONFIG_TASK_NAME_SIZE] = '\0';
|
||||||
#endif /* CONFIG_TASK_NAME_SIZE */
|
#endif /* CONFIG_TASK_NAME_SIZE */
|
||||||
|
|
||||||
@@ -404,11 +395,14 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
parent = this_task();
|
||||||
|
DEBUGASSERT(parent != NULL);
|
||||||
|
|
||||||
/* Configure the TCB for a pthread receiving on parameter
|
/* Configure the TCB for a pthread receiving on parameter
|
||||||
* passed by value
|
* passed by value
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pthread_tcb_setup(ptcb, trampoline, arg);
|
pthread_tcb_setup(ptcb, parent, trampoline, arg);
|
||||||
|
|
||||||
/* Join the parent's task group */
|
/* Join the parent's task group */
|
||||||
|
|
||||||
@@ -473,9 +467,6 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread,
|
|||||||
* so it has the same priority as the parent thread.
|
* so it has the same priority as the parent thread.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
parent = this_task();
|
|
||||||
DEBUGASSERT(parent != NULL);
|
|
||||||
|
|
||||||
if (ptcb->cmn.sched_priority < parent->sched_priority)
|
if (ptcb->cmn.sched_priority < parent->sched_priority)
|
||||||
{
|
{
|
||||||
ret = nxsched_set_priority(&ptcb->cmn, parent->sched_priority);
|
ret = nxsched_set_priority(&ptcb->cmn, parent->sched_priority);
|
||||||
|
|||||||
Reference in New Issue
Block a user