You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/12/11 12:12:27 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 opened a new pull request #2518: sched: Implement getpid and gettid correctly

xiaoxiang781216 opened a new pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518


   ## Summary
   getpid should return the main thread id
   gettid should return the current thread id
   See the discussion here: https://github.com/apache/incubator-nuttx/issues/2499
   
   ## Impact
   
   ## Testing
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#discussion_r587722217



##########
File path: sched/task/task_gettid.c
##########
@@ -45,5 +50,42 @@
 
 pid_t gettid(void)
 {
-  return getpid();
+  FAR struct tcb_s *rtcb;
+
+  /* Get the TCB at the head of the ready-to-run task list.  That
+   * will usually be the currently executing task.  There is are two

Review comment:
       Done.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] yamt commented on pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
yamt commented on pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#issuecomment-765102556


   what's the plan for pid_t taking APIs like kill and wait?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2518: sched: Don't forward gettid to getpid directly

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#discussion_r587980736



##########
File path: sched/task/task_gettid.c
##########
@@ -45,5 +50,42 @@
 
 pid_t gettid(void)
 {
-  return getpid();
+  FAR struct tcb_s *rtcb;
+
+  /* Get the TCB at the head of the ready-to-run task list.  That
+   * will usually be the currently executing task.  There are two
+   * exceptions to this:
+   *
+   * 1. Early in the start-up sequence, the ready-to-run list may be
+   *    empty!  In this case, of course, the CPU0 start-up/IDLE thread with
+   *    pid == 0 must be running, and
+   * 2. As described above, during certain context-switching conditions the
+   *    task at the head of the ready-to-run list may not actually be
+   *    running.
+   */
+
+  rtcb = this_task();
+  if (rtcb != NULL)
+    {
+      /* Check if the task is actually running */
+
+      if (rtcb->task_state == TSTATE_TASK_RUNNING)
+        {
+          /* Yes.. Return the task ID from the TCB at the head of the
+           * ready-to-run task list
+           */
+
+          return rtcb->pid;

Review comment:
       Ok, I will create a new PR to rename this field.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#discussion_r540951299



##########
File path: sched/task/task_getpid.c
##########
@@ -95,11 +95,17 @@ pid_t getpid(void)
 
       if (rtcb->task_state == TSTATE_TASK_RUNNING)
         {
+#if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SCHED_HAVE_PARENT)
+          /* Yes.. Return the task ID from the main TCB */

Review comment:
       Ok, I will change the definition too in the next update.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#discussion_r540951299



##########
File path: sched/task/task_getpid.c
##########
@@ -95,11 +95,17 @@ pid_t getpid(void)
 
       if (rtcb->task_state == TSTATE_TASK_RUNNING)
         {
+#if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SCHED_HAVE_PARENT)
+          /* Yes.. Return the task ID from the main TCB */

Review comment:
       Ok, I will change the definition too.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] patacongo commented on a change in pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
patacongo commented on a change in pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#discussion_r587774907



##########
File path: sched/task/task_gettid.c
##########
@@ -45,5 +50,42 @@
 
 pid_t gettid(void)
 {
-  return getpid();
+  FAR struct tcb_s *rtcb;
+
+  /* Get the TCB at the head of the ready-to-run task list.  That
+   * will usually be the currently executing task.  There are two
+   * exceptions to this:
+   *
+   * 1. Early in the start-up sequence, the ready-to-run list may be
+   *    empty!  In this case, of course, the CPU0 start-up/IDLE thread with
+   *    pid == 0 must be running, and
+   * 2. As described above, during certain context-switching conditions the
+   *    task at the head of the ready-to-run list may not actually be
+   *    running.
+   */
+
+  rtcb = this_task();
+  if (rtcb != NULL)
+    {
+      /* Check if the task is actually running */
+
+      if (rtcb->task_state == TSTATE_TASK_RUNNING)
+        {
+          /* Yes.. Return the task ID from the TCB at the head of the
+           * ready-to-run task list
+           */
+
+          return rtcb->pid;

Review comment:
       We will need to rename the pid field in tcb.s to tid.  This will effect a lot of files, but is not a risky change otherwise.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#discussion_r540943083



##########
File path: sched/task/task_getpid.c
##########
@@ -95,11 +95,17 @@ pid_t getpid(void)
 
       if (rtcb->task_state == TSTATE_TASK_RUNNING)
         {
+#if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SCHED_HAVE_PARENT)
+          /* Yes.. Return the task ID from the main TCB */

Review comment:
       Because the definition use the same condition(https://github.com/apache/incubator-nuttx/blob/master/include/nuttx/sched.h#L475):
   ```
   struct task_group_s
   {
   #if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SCHED_HAVE_PARENT)
     pid_t tg_task;                    /* The ID of the task within the group      */
   #endif
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] patacongo commented on pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
patacongo commented on pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#issuecomment-743446674


   There is some naming that should be made consistent too.  In the TCB, the pid field should be called tid, for example.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#issuecomment-789383285


   > Perhaps we could put the changes on a branch. I could help out some with the conversion.
   > 
   
   Thanks for helping.
   
   > However, we should wait until after the next 10.1.x release to give the changes as much time as possible to mature before 10.2.
   >
   
   Sure, I will create a branch once the new release is out.
    
   > There should be no real use of the (corrected) getpid within the OS other than at the OS API. There are several functions that take the pid as a parameter (and usually if the pid is zero, then it should use getpid() to get the pid of the caller). I suppose these should return only information for the main thread:
   > 
   > ```
   > sched.h:int    task_delete(pid_t pid);
   > sched.h:int    task_restart(pid_t pid);
   > sched.h:int    sched_setparam(pid_t pid, FAR const struct sched_param *param);
   > sched.h:int    sched_getparam(pid_t pid, FAR struct sched_param *param);
   > sched.h:int    sched_setscheduler(pid_t pid, int policy,
   > sched.h:int    sched_getscheduler(pid_t pid);
   > sched.h:int    sched_rr_get_interval(pid_t pid, FAR struct timespec *interval);
   > sched.h:int    sched_setaffinity(pid_t pid, size_t cpusetsize,
   > sched.h:int    sched_getaffinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask);
   > signal.h:int  kill(pid_t pid, int signo);
   > spawn.h:int posix_spawnp(FAR pid_t *pid, FAR const char *path,
   > spawn.h:int posix_spawn(FAR pid_t *pid, FAR const char *path,
   > spawn.h:int task_spawn(FAR pid_t *pid, FAR const char *name, main_t entry,
   > termios.h:pid_t tcgetsid(int fd);
   > unistd.h:pid_t   vfork(void);
   > unistd.h:pid_t   getpid(void);
   > unistd.h:pid_t   gettid(void);
   > unistd.h:pid_t   getppid(void);
   > ```
   > 
   > And for some associated system calls:
   > 
   > ```
   > sched.h:FAR struct tcb_s *nxsched_get_tcb(pid_t pid);
   > sched.h:pid_t nxtask_start_vfork(FAR struct task_tcb_s *child);
   > sched.h:int group_exitinfo(pid_t pid, FAR struct binary_s *bininfo);
   > sched.h:int nxsched_get_param (pid_t pid, FAR struct sched_param *param);
   > sched.h:int nxsched_set_param(pid_t pid, FAR const struct sched_param *param);
   > sched.h:int nxsched_get_scheduler(pid_t pid);
   > sched.h:int nxsched_set_scheduler(pid_t pid, int policy,
   > sched.h:int nxsched_get_affinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask);
   > sched.h:int nxsched_set_affinity(pid_t pid, size_t cpusetsize,
   > sched.h:int nxsched_get_stackinfo(pid_t pid, FAR struct stackinfo_s *stackinfo);
   > sched.h:pid_t nx_wait(FAR int *stat_loc);
   > sched.h:pid_t nx_waitpid(pid_t pid, FAR int *stat_loc, int options);
   > signal.h:int nxsig_kill(pid_t pid, int signo);
   > signal.h:int nxsig_notification(pid_t pid, FAR struct sigevent *event,
   > ```
   > 
   > Within the OS, I think that all of the internal calls to getpid() can be converted gettid().
   > 
   > There is also a lot of naming of variables and structure fields that would need to be corrected.
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] patacongo commented on pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
patacongo commented on pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#issuecomment-743184614


   This line in pthread.h needs to change too:
   
   #define pthread_self() ((pthread_t)getpid())
   
   Please review all uses of getpid() in the OS and make sure that the calls still make sense.  In most cases, getpid() will need to be replaces with gettid() or pthread_self().
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] patacongo commented on a change in pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
patacongo commented on a change in pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#discussion_r540937984



##########
File path: sched/task/task_getpid.c
##########
@@ -95,11 +95,17 @@ pid_t getpid(void)
 
       if (rtcb->task_state == TSTATE_TASK_RUNNING)
         {
+#if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SCHED_HAVE_PARENT)
+          /* Yes.. Return the task ID from the main TCB */

Review comment:
       I think that this change should apply even if CONFIG_SCHED_HAVE_PARENT is not defined, should it not?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] patacongo commented on pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
patacongo commented on pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#issuecomment-788925892


   Perhaps we could put the changes on a branch.  I could help out some with the conversion.
   
   However, we should wait until after the next 10.1.x release to give the changes as much time as possible to mature before 10.2.
   
   There should be no real use of the (corrected) getpid within the OS other than at the OS API.  There are several functions that take the pid as a parameter (and usually if the pid is zero, then it should use getpid() to get the pid of the caller).  I suppose these should return only information for the main thread:
   
   ```
   sched.h:int    task_delete(pid_t pid);
   sched.h:int    task_restart(pid_t pid);
   sched.h:int    sched_setparam(pid_t pid, FAR const struct sched_param *param);
   sched.h:int    sched_getparam(pid_t pid, FAR struct sched_param *param);
   sched.h:int    sched_setscheduler(pid_t pid, int policy,
   sched.h:int    sched_getscheduler(pid_t pid);
   sched.h:int    sched_rr_get_interval(pid_t pid, FAR struct timespec *interval);
   sched.h:int    sched_setaffinity(pid_t pid, size_t cpusetsize,
   sched.h:int    sched_getaffinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask);
   signal.h:int  kill(pid_t pid, int signo);
   spawn.h:int posix_spawnp(FAR pid_t *pid, FAR const char *path,
   spawn.h:int posix_spawn(FAR pid_t *pid, FAR const char *path,
   spawn.h:int task_spawn(FAR pid_t *pid, FAR const char *name, main_t entry,
   termios.h:pid_t tcgetsid(int fd);
   unistd.h:pid_t   vfork(void);
   unistd.h:pid_t   getpid(void);
   unistd.h:pid_t   gettid(void);
   unistd.h:pid_t   getppid(void);
   ```
   
   And for some associated system calls:
   
   ```
   sched.h:FAR struct tcb_s *nxsched_get_tcb(pid_t pid);
   sched.h:pid_t nxtask_start_vfork(FAR struct task_tcb_s *child);
   sched.h:int group_exitinfo(pid_t pid, FAR struct binary_s *bininfo);
   sched.h:int nxsched_get_param (pid_t pid, FAR struct sched_param *param);
   sched.h:int nxsched_set_param(pid_t pid, FAR const struct sched_param *param);
   sched.h:int nxsched_get_scheduler(pid_t pid);
   sched.h:int nxsched_set_scheduler(pid_t pid, int policy,
   sched.h:int nxsched_get_affinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask);
   sched.h:int nxsched_set_affinity(pid_t pid, size_t cpusetsize,
   sched.h:int nxsched_get_stackinfo(pid_t pid, FAR struct stackinfo_s *stackinfo);
   sched.h:pid_t nx_wait(FAR int *stat_loc);
   sched.h:pid_t nx_waitpid(pid_t pid, FAR int *stat_loc, int options);
   signal.h:int nxsig_kill(pid_t pid, int signo);
   signal.h:int nxsig_notification(pid_t pid, FAR struct sigevent *event,
   
   ```
   Within the OS, I think that all of the internal calls to getpid() can be converted gettid().
   
   There is also a lot of naming of variables and structure fields that would need to be corrected.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#issuecomment-743190424


   > This line in pthread.h needs to change too:
   > 
   > #define pthread_self() ((pthread_t)getpid())
   > 
   > Please review all uses of getpid() in the OS and make sure that the calls still make sense. In most cases, getpid() will need to be replaces with gettid() or pthread_self().
   
   Yes, I will review all place and ensure all usage is correct.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] patacongo commented on pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
patacongo commented on pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#issuecomment-765112999


   > 
   > 
   > what's the plan for pid_t taking APIs like kill and wait?
   
   Those are POSIX APIs and are required to use a process ID as would be returned by getpid().
   
   gettid() is a non-standard Linux API that really should not be used in portable software.  The standard, portable interfaces are getpid() and pthread_self().
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#discussion_r558337841



##########
File path: sched/task/task_gettid.c
##########
@@ -45,5 +50,42 @@
 
 pid_t gettid(void)
 {
-  return getpid();
+  FAR struct tcb_s *rtcb;
+
+  /* Get the TCB at the head of the ready-to-run task list.  That
+   * will usually be the currently executing task.  There is are two

Review comment:
       ```suggestion
      * will usually be the currently executing task.  There are two
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] patacongo commented on a change in pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
patacongo commented on a change in pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#discussion_r540950040



##########
File path: sched/task/task_getpid.c
##########
@@ -95,11 +95,17 @@ pid_t getpid(void)
 
       if (rtcb->task_state == TSTATE_TASK_RUNNING)
         {
+#if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SCHED_HAVE_PARENT)
+          /* Yes.. Return the task ID from the main TCB */

Review comment:
       > 
   > 
   > Because the definition use the same condition(https://github.com/apache/incubator-nuttx/blob/master/include/nuttx/sched.h#L475):
   > 
   > ```
   > struct task_group_s
   > {
   > #if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SCHED_HAVE_PARENT)
   >   pid_t tg_task;                    /* The ID of the task within the group      */
   > #endif
   > ```
   
   That is my point.  The definition should change. tg_task should be initialized and available in all configurations.  Otherwise, getpid() will return a bad value in some configurations.
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] patacongo removed a comment on pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
patacongo removed a comment on pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#issuecomment-788924592


   Perhaps we could put the changes on a branch.  I could help out some with the conversion.
   
   However, we should wait until after the next 10.1.x release to give the changes as much time as possible to mature before 10.2.
   
   There should be no real use of the (corrected) getpid within the OS other than at the OS API.  There are several functions that take the pid as a parameter (and usually if the pid is zero, then it should use getpid() to get the pid of the caller).  I suppose these should return only information for the main thread:
   
   ```
   sched.h:int    task_delete(pid_t pid);
   sched.h:int    task_restart(pid_t pid);
   sched.h:int    sched_setparam(pid_t pid, FAR const struct sched_param *param);
   sched.h:int    sched_getparam(pid_t pid, FAR struct sched_param *param);
   sched.h:int    sched_setscheduler(pid_t pid, int policy,
   sched.h:int    sched_getscheduler(pid_t pid);
   sched.h:int    sched_rr_get_interval(pid_t pid, FAR struct timespec *interval);
   sched.h:int    sched_setaffinity(pid_t pid, size_t cpusetsize,
   sched.h:int    sched_getaffinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask);
   signal.h:int  kill(pid_t pid, int signo);
   spawn.h:int posix_spawnp(FAR pid_t *pid, FAR const char *path,
   spawn.h:int posix_spawn(FAR pid_t *pid, FAR const char *path,
   spawn.h:int task_spawn(FAR pid_t *pid, FAR const char *name, main_t entry,
   termios.h:pid_t tcgetsid(int fd);
   unistd.h:pid_t   vfork(void);
   unistd.h:pid_t   getpid(void);
   unistd.h:pid_t   gettid(void);
   unistd.h:pid_t   getppid(void);
   ```
   
   And for some associated system calls:
   
   ```
   sched.h:FAR struct tcb_s *nxsched_get_tcb(pid_t pid);
   sched.h:pid_t nxtask_start_vfork(FAR struct task_tcb_s *child);
   sched.h:int group_exitinfo(pid_t pid, FAR struct binary_s *bininfo);
   sched.h:int nxsched_get_param (pid_t pid, FAR struct sched_param *param);
   sched.h:int nxsched_set_param(pid_t pid, FAR const struct sched_param *param);
   sched.h:int nxsched_get_scheduler(pid_t pid);
   sched.h:int nxsched_set_scheduler(pid_t pid, int policy,
   sched.h:int nxsched_get_affinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask);
   sched.h:int nxsched_set_affinity(pid_t pid, size_t cpusetsize,
   sched.h:int nxsched_get_stackinfo(pid_t pid, FAR struct stackinfo_s *stackinfo);
   sched.h:pid_t nx_wait(FAR int *stat_loc);
   sched.h:pid_t nx_waitpid(pid_t pid, FAR int *stat_loc, int options);
   signal.h:int nxsig_kill(pid_t pid, int signo);
   signal.h:int nxsig_notification(pid_t pid, FAR struct sigevent *event,
   
   ```
   Within the OS, I think that all of the internal calls to getpid() can be converted gettid().
   
   There is also a lot of naming of variables and structure fields that would need to be corrected.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] yamt commented on pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
yamt commented on pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#issuecomment-765102556


   what's the plan for pid_t taking APIs like kill and wait?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] patacongo commented on pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
patacongo commented on pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#issuecomment-788924592


   Perhaps we could put the changes on a branch.  I could help out some with the conversion.
   
   However, we should wait until after the next 10.1.x release to give the changes as much time as possible to mature before 10.2.
   
   There should be no real use of the (corrected) getpid within the OS other than at the OS API.  There are several functions that take the pid as a parameter (and usually if the pid is zero, then it should use getpid() to get the pid of the caller).  I suppose these should return only information for the main thread:
   
   ```
   sched.h:int    task_delete(pid_t pid);
   sched.h:int    task_restart(pid_t pid);
   sched.h:int    sched_setparam(pid_t pid, FAR const struct sched_param *param);
   sched.h:int    sched_getparam(pid_t pid, FAR struct sched_param *param);
   sched.h:int    sched_setscheduler(pid_t pid, int policy,
   sched.h:int    sched_getscheduler(pid_t pid);
   sched.h:int    sched_rr_get_interval(pid_t pid, FAR struct timespec *interval);
   sched.h:int    sched_setaffinity(pid_t pid, size_t cpusetsize,
   sched.h:int    sched_getaffinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask);
   signal.h:int  kill(pid_t pid, int signo);
   spawn.h:int posix_spawnp(FAR pid_t *pid, FAR const char *path,
   spawn.h:int posix_spawn(FAR pid_t *pid, FAR const char *path,
   spawn.h:int task_spawn(FAR pid_t *pid, FAR const char *name, main_t entry,
   termios.h:pid_t tcgetsid(int fd);
   unistd.h:pid_t   vfork(void);
   unistd.h:pid_t   getpid(void);
   unistd.h:pid_t   gettid(void);
   unistd.h:pid_t   getppid(void);
   ```
   
   And for some associated system calls:
   
   ```
   sched.h:FAR struct tcb_s *nxsched_get_tcb(pid_t pid);
   sched.h:pid_t nxtask_start_vfork(FAR struct task_tcb_s *child);
   sched.h:int group_exitinfo(pid_t pid, FAR struct binary_s *bininfo);
   sched.h:int nxsched_get_param (pid_t pid, FAR struct sched_param *param);
   sched.h:int nxsched_set_param(pid_t pid, FAR const struct sched_param *param);
   sched.h:int nxsched_get_scheduler(pid_t pid);
   sched.h:int nxsched_set_scheduler(pid_t pid, int policy,
   sched.h:int nxsched_get_affinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask);
   sched.h:int nxsched_set_affinity(pid_t pid, size_t cpusetsize,
   sched.h:int nxsched_get_stackinfo(pid_t pid, FAR struct stackinfo_s *stackinfo);
   sched.h:pid_t nx_wait(FAR int *stat_loc);
   sched.h:pid_t nx_waitpid(pid_t pid, FAR int *stat_loc, int options);
   signal.h:int nxsig_kill(pid_t pid, int signo);
   signal.h:int nxsig_notification(pid_t pid, FAR struct sigevent *event,
   
   ```
   Within the OS, I think that all of the internal calls to getpid() can be converted gettid().
   
   There is also a lot of naming of variables and structure fields that would need to be corrected.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#issuecomment-790841415


   @patacongo I remove getpid change from PR, so we can merge this one first.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] patacongo commented on pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
patacongo commented on pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#issuecomment-765112999


   > 
   > 
   > what's the plan for pid_t taking APIs like kill and wait?
   
   Those are POSIX APIs and are required to use a process ID as would be returned by getpid().
   
   gettid() is a non-standard Linux API that really should not be used in portable software.  The standard, portable interfaces are getpid() and pthread_self().
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] patacongo merged pull request #2518: sched: Implement getpid and gettid correctly

Posted by GitBox <gi...@apache.org>.
patacongo merged pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org