sched/task: add kernel interface nxsched_* gettid/getpid/getppid
add new interface to implement getpid()/gettid()/getppid() for kernel version. Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
parent
c9981036a5
commit
c24dc389e4
@ -166,6 +166,16 @@
|
||||
# define _SCHED_ERRVAL(r) (-errno)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
|
||||
# define _SCHED_GETTID() nxsched_gettid()
|
||||
# define _SCHED_GETPID() nxsched_getpid()
|
||||
# define _SCHED_GETPPID() nxsched_getppid()
|
||||
#else
|
||||
# define _SCHED_GETTID() gettid()
|
||||
# define _SCHED_GETPID() getpid()
|
||||
# define _SCHED_GETPPID() getppid()
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_TCBINFO
|
||||
# define TCB_PID_OFF offsetof(struct tcb_s, pid)
|
||||
# define TCB_STATE_OFF offsetof(struct tcb_s, task_state)
|
||||
@ -1408,6 +1418,67 @@ int nxsched_get_stackinfo(pid_t pid, FAR struct stackinfo_s *stackinfo);
|
||||
pid_t nxsched_waitpid(pid_t pid, FAR int *stat_loc, int options);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsched_gettid
|
||||
*
|
||||
* Description:
|
||||
* Get the thread ID of the currently executing thread.
|
||||
*
|
||||
* Input parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, returns the thread ID of the calling process.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
pid_t nxsched_gettid(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsched_getpid
|
||||
*
|
||||
* Description:
|
||||
* Get the Process ID of the currently executing task.
|
||||
*
|
||||
* Input parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Normally when called from user applications, nxsched_getpid() will
|
||||
* return the Process ID of the currently executing task. that is,
|
||||
* the main task for the task groups. There is no specification for
|
||||
* any errors returned from nxsched_getpid().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
pid_t nxsched_getpid(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsched_getppid
|
||||
*
|
||||
* Description:
|
||||
* Get the parent task ID of the currently executing task.
|
||||
*
|
||||
* Input parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Normally when called from user applications, nxsched_getppid() will
|
||||
* return the parent task ID of the currently executing task, that is,
|
||||
* the task at the head of the ready-to-run list.
|
||||
* There is no specification for any errors returned from
|
||||
* nxsched_getppid().
|
||||
*
|
||||
* nxsched_getppid(), however, may be called from within the OS in some
|
||||
* cases. There are certain situations during context switching when the
|
||||
* OS data structures are in flux and where the current task at the head
|
||||
* of the ready-to-run task list is not actually running.
|
||||
* In that case, nxsched_getppid() will return the error: -ESRCH
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
pid_t nxsched_getppid(void);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
@ -35,7 +35,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: getpid
|
||||
* Name: nxsched_getpid
|
||||
*
|
||||
* Description:
|
||||
* Get the Process ID of the currently executing task.
|
||||
@ -44,14 +44,14 @@
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Normally when called from user applications, getpid() will return the
|
||||
* Process ID of the currently executing task. that is, the main task
|
||||
* for the task groups. There is no specification for any errors
|
||||
* returned from getpid().
|
||||
* Normally when called from user applications, nxsched_getpid() will
|
||||
* return the Process ID of the currently executing task. that is,
|
||||
* the main task for the task groups. There is no specification for
|
||||
* any errors returned from nxsched_getpid().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
pid_t getpid(void)
|
||||
pid_t nxsched_getpid(void)
|
||||
{
|
||||
FAR struct tcb_s *rtcb;
|
||||
|
||||
@ -78,3 +78,25 @@ pid_t getpid(void)
|
||||
|
||||
return IDLE_PROCESS_ID;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: getpid
|
||||
*
|
||||
* Description:
|
||||
* Get the Process ID of the currently executing task.
|
||||
*
|
||||
* Input parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Normally when called from user applications, getpid() will return the
|
||||
* Process ID of the currently executing task. that is, the main task
|
||||
* for the task groups. There is no specification for any errors
|
||||
* returned from getpid().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
pid_t getpid(void)
|
||||
{
|
||||
return nxsched_getpid();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: getppid
|
||||
* Name: nxsched_getppid
|
||||
*
|
||||
* Description:
|
||||
* Get the parent task ID of the currently executing task.
|
||||
@ -44,20 +44,21 @@
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Normally when called from user applications, getppid() will return the
|
||||
* parent task ID of the currently executing task, that is, the task at the
|
||||
* head of the ready-to-run list. There is no specification for any errors
|
||||
* returned from getppid().
|
||||
* Normally when called from user applications, nxsched_getppid() will
|
||||
* return the parent task ID of the currently executing task, that is,
|
||||
* the task at the head of the ready-to-run list.
|
||||
* There is no specification for any errors returned from
|
||||
* nxsched_getppid().
|
||||
*
|
||||
* getppid(), however, may be called from within the OS in some cases.
|
||||
* There are certain situations during context switching when the OS data
|
||||
* structures are in flux and where the current task at the head of the
|
||||
* ready-to-run task list is not actually running. In that case,
|
||||
* getppid() will return the error: -ESRCH
|
||||
* nxsched_getppid(), however, may be called from within the OS in some
|
||||
* cases. There are certain situations during context switching when the
|
||||
* OS data structures are in flux and where the current task at the head
|
||||
* of the ready-to-run task list is not actually running.
|
||||
* In that case, nxsched_getppid() will return the error: -ESRCH
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
pid_t getppid(void)
|
||||
pid_t nxsched_getppid(void)
|
||||
{
|
||||
FAR struct tcb_s *rtcb;
|
||||
|
||||
@ -98,3 +99,31 @@ pid_t getppid(void)
|
||||
|
||||
return IDLE_PROCESS_ID;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: getppid
|
||||
*
|
||||
* Description:
|
||||
* Get the parent task ID of the currently executing task.
|
||||
*
|
||||
* Input parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Normally when called from user applications, getppid() will return the
|
||||
* parent task ID of the currently executing task, that is, the task at the
|
||||
* head of the ready-to-run list. There is no specification for any errors
|
||||
* returned from getppid().
|
||||
*
|
||||
* getppid(), however, may be called from within the OS in some cases.
|
||||
* There are certain situations during context switching when the OS data
|
||||
* structures are in flux and where the current task at the head of the
|
||||
* ready-to-run task list is not actually running. In that case,
|
||||
* getppid() will return the error: -ESRCH
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
pid_t getppid(void)
|
||||
{
|
||||
return nxsched_getppid();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gettid
|
||||
* Name: nxsched_gettid
|
||||
*
|
||||
* Description:
|
||||
* Get the thread ID of the currently executing thread.
|
||||
@ -48,7 +48,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
pid_t gettid(void)
|
||||
pid_t nxsched_gettid(void)
|
||||
{
|
||||
FAR struct tcb_s *rtcb;
|
||||
|
||||
@ -89,3 +89,22 @@ pid_t gettid(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gettid
|
||||
*
|
||||
* Description:
|
||||
* Get the thread ID of the currently executing thread.
|
||||
*
|
||||
* Input parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, returns the thread ID of the calling process.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
pid_t gettid(void)
|
||||
{
|
||||
return nxsched_gettid();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user