mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-29 03:13:33 +08:00
Fix instrumenation in task_delete(); fix prctl parameter order
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4659 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
+28
-2
@@ -88,9 +88,29 @@ int prctl(int option, ...)
|
|||||||
case PR_GET_NAME:
|
case PR_GET_NAME:
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
#if CONFIG_TASK_NAME_SIZE > 0
|
||||||
{
|
{
|
||||||
int pid = va_arg(ap, int);
|
/* Get the prctl arguments */
|
||||||
|
|
||||||
char *name = va_arg(ap, char *);
|
char *name = va_arg(ap, char *);
|
||||||
FAR _TCB *tcb = sched_gettcb(pid);
|
int pid = va_arg(ap, int);
|
||||||
|
FAR _TCB *tcb;
|
||||||
|
|
||||||
|
/* Get the TCB associated with the PID (handling the special case of
|
||||||
|
* pid==0 meaning "this thread"
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!pid)
|
||||||
|
{
|
||||||
|
tcb = (FAR _TCB *)g_readytorun.head;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tcb = sched_gettcb(pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* An invalid pid be indicated by a NULL TCB returned from
|
||||||
|
* sched_gettcb()
|
||||||
|
*/
|
||||||
|
|
||||||
if (!tcb)
|
if (!tcb)
|
||||||
{
|
{
|
||||||
sdbg("Pid does not correspond to a task: %d\n", pid);
|
sdbg("Pid does not correspond to a task: %d\n", pid);
|
||||||
@@ -105,12 +125,18 @@ int prctl(int option, ...)
|
|||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Now get or set the name */
|
||||||
|
|
||||||
if (option == PR_SET_NAME)
|
if (option == PR_SET_NAME)
|
||||||
{
|
{
|
||||||
|
/* tcb->name may not be null-terminated */
|
||||||
|
|
||||||
strncpy(tcb->name, name, CONFIG_TASK_NAME_SIZE);
|
strncpy(tcb->name, name, CONFIG_TASK_NAME_SIZE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* The returned value will be null-terminated, truncating if necessary */
|
||||||
|
|
||||||
strncpy(name, tcb->name, CONFIG_TASK_NAME_SIZE-1);
|
strncpy(name, tcb->name, CONFIG_TASK_NAME_SIZE-1);
|
||||||
name[CONFIG_TASK_NAME_SIZE-1];
|
name[CONFIG_TASK_NAME_SIZE-1];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ int task_delete(pid_t pid)
|
|||||||
* layer that the task no longer exists.
|
* layer that the task no longer exists.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sched_note_stop(tcb);
|
sched_note_stop(dtcb);
|
||||||
|
|
||||||
/* Deallocate its TCB */
|
/* Deallocate its TCB */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user