note: directly returns the taskname pointer
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
parent
63252af054
commit
4cb2d7dc25
@ -177,8 +177,7 @@ FAR static struct note_driver_s *
|
|||||||
static struct note_taskname_s g_note_taskname;
|
static struct note_taskname_s g_note_taskname;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_SCHED_INSTRUMENTATION_FILTER) || \
|
#if defined(CONFIG_SCHED_INSTRUMENTATION_FILTER)
|
||||||
(CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0)
|
|
||||||
static spinlock_t g_note_lock;
|
static spinlock_t g_note_lock;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1933,39 +1932,29 @@ void sched_note_filter_tag(FAR struct note_filter_tag_s *oldf,
|
|||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* PID - Task ID
|
* PID - Task ID
|
||||||
* name - Task name buffer
|
|
||||||
* this buffer must be greater than CONFIG_TASK_NAME_SIZE + 1
|
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Retrun OK if task name can be retrieved, otherwise -ESRCH
|
* Retrun name if task name can be retrieved, otherwise NULL
|
||||||
*
|
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int note_get_taskname(pid_t pid, FAR char *buffer)
|
FAR const char *note_get_taskname(pid_t pid)
|
||||||
{
|
{
|
||||||
FAR struct note_taskname_info_s *ti;
|
FAR struct note_taskname_info_s *ti;
|
||||||
FAR struct tcb_s *tcb;
|
FAR struct tcb_s *tcb;
|
||||||
irqstate_t irq_mask;
|
|
||||||
|
|
||||||
irq_mask = spin_lock_irqsave_wo_note(&g_note_lock);
|
|
||||||
tcb = nxsched_get_tcb(pid);
|
tcb = nxsched_get_tcb(pid);
|
||||||
if (tcb != NULL)
|
if (tcb != NULL)
|
||||||
{
|
{
|
||||||
strlcpy(buffer, tcb->name, CONFIG_TASK_NAME_SIZE + 1);
|
return tcb->name;
|
||||||
spin_unlock_irqrestore_wo_note(&g_note_lock, irq_mask);
|
|
||||||
return OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ti = note_find_taskname(pid);
|
ti = note_find_taskname(pid);
|
||||||
if (ti != NULL)
|
if (ti != NULL)
|
||||||
{
|
{
|
||||||
strlcpy(buffer, ti->name, CONFIG_TASK_NAME_SIZE + 1);
|
return ti->name;
|
||||||
spin_unlock_irqrestore_wo_note(&g_note_lock, irq_mask);
|
|
||||||
return OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock_irqrestore_wo_note(&g_note_lock, irq_mask);
|
return NULL;
|
||||||
return -ESRCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -829,11 +829,10 @@ get_task_context(pid_t pid, FAR struct noteram_dump_context_s *ctx)
|
|||||||
|
|
||||||
#ifdef CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE
|
#ifdef CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE
|
||||||
{
|
{
|
||||||
char taskname[CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE];
|
FAR const char *taskname;
|
||||||
int res;
|
|
||||||
|
|
||||||
res = note_get_taskname(pid, taskname);
|
taskname = note_get_taskname(pid);
|
||||||
if (res == 0)
|
if (taskname != NULL)
|
||||||
{
|
{
|
||||||
copy_task_name((*tctxp)->name, taskname);
|
copy_task_name((*tctxp)->name, taskname);
|
||||||
}
|
}
|
||||||
|
@ -145,15 +145,13 @@ int note_initialize(void);
|
|||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* PID - Task ID
|
* PID - Task ID
|
||||||
* name - Task name buffer
|
|
||||||
* this buffer must be greater than CONFIG_TASK_NAME_SIZE + 1
|
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Retrun OK if task name can be retrieved, otherwise -ESRCH
|
* Retrun name if task name can be retrieved, otherwise NULL
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int note_get_taskname(pid_t pid, FAR char *name);
|
FAR const char *note_get_taskname(pid_t pid);
|
||||||
|
|
||||||
#endif /* defined(CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE) && \
|
#endif /* defined(CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE) && \
|
||||||
* CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0
|
* CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0
|
||||||
|
Loading…
Reference in New Issue
Block a user