xiaoxiang781216 commented on code in PR #11848:
URL: https://github.com/apache/nuttx/pull/11848#discussion_r1515354540


##########
fs/procfs/fs_procfsproc.c:
##########
@@ -1202,10 +1205,12 @@ static ssize_t proc_groupstatus(FAR struct proc_file_s 
*procfile,
       return totalsize;
     }
 
-  for (i = 0; i < group->tg_nmembers; i++)
+  sq_for_every_safe(&group->tg_members, curr, next)
     {
+      FAR struct tcb_s *mtcb =

Review Comment:
   can reuse tcb?



##########
sched/group/group_foreachchild.c:
##########
@@ -58,23 +60,27 @@
 int group_foreachchild(FAR struct task_group_s *group,
                        foreachchild_t handler, FAR void *arg)
 {
+  FAR sq_entry_t *curr;
+  FAR sq_entry_t *next;
   int ret;
-  int i;
 
   DEBUGASSERT(group);
 
   /* Visit the main thread last (if present) */
 
-  for (i = group->tg_nmembers - 1; i >= 0; i--)
+  sq_for_every_safe(&group->tg_members, curr, next)
     {
-      ret = handler(group->tg_members[i], arg);
-      if (ret != 0)
+      FAR struct tcb_s *mtcb =

Review Comment:
   mtcb->tcb



##########
sched/clock/clock_gettime.c:
##########
@@ -183,20 +188,24 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
 
       if (tcb != NULL)
         {
+# ifdef HAVE_GROUP_MEMBERS
           group = tcb->group;
           runtime = 0;
 
-          flags = enter_critical_section();
-          for (i = group->tg_nmembers - 1; i >= 0; i--)
+          flags = spin_lock_irqsave_wo_note(NULL);
+          sq_for_every_safe(&group->tg_members, curr, next)
             {
-              tcb = nxsched_get_tcb(group->tg_members[i]);
-              if (tcb != NULL)
-                {
-                  runtime += tcb->run_time;
-                }
+              FAR struct tcb_s *mtcb =

Review Comment:
   could reuse tcb too?



##########
sched/group/group_join.c:
##########
@@ -203,32 +97,19 @@ int group_bind(FAR struct pthread_tcb_s *tcb)
 int group_join(FAR struct pthread_tcb_s *tcb)
 {
   FAR struct task_group_s *group;
-#ifdef HAVE_GROUP_MEMBERS
-  int ret;
-#else
   irqstate_t flags;
-#endif
 
-  DEBUGASSERT(tcb && tcb->cmn.group &&
-              tcb->cmn.group->tg_nmembers < UINT8_MAX);
+  DEBUGASSERT(tcb && tcb->cmn.group);
 
   /* Get the group from the TCB */
 
   group = tcb->cmn.group;
 
-#ifdef HAVE_GROUP_MEMBERS
   /* Add the member to the group */
 
-  ret = group_addmember(group, tcb->cmn.pid);
-  if (ret < 0)
-    {
-      return ret;
-    }
-#else
-  flags = spin_lock_irqsave(NULL);
-  group->tg_nmembers++;
-  spin_unlock_irqrestore(NULL, flags);
-#endif
+  flags = spin_lock_irqsave_wo_note(NULL);

Review Comment:
   spin_lock_irqsave



##########
sched/clock/clock_gettime.c:
##########
@@ -183,20 +188,24 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
 
       if (tcb != NULL)
         {
+# ifdef HAVE_GROUP_MEMBERS
           group = tcb->group;
           runtime = 0;
 
-          flags = enter_critical_section();
-          for (i = group->tg_nmembers - 1; i >= 0; i--)
+          flags = spin_lock_irqsave_wo_note(NULL);

Review Comment:
   spin_lock_irqsave



##########
sched/group/group_leave.c:
##########
@@ -226,17 +166,17 @@ void group_leave(FAR struct tcb_s *tcb)
   group = tcb->group;
   if (group)
     {
-      /* Remove the member from group.  This function may be called
-       * during certain error handling before the PID has been
-       * added to the group.  In this case tcb->pid will be uninitialized
-       * group_removemember() will fail.
-       */
+      /* Remove the member from group. */
 
-      group_removemember(group, tcb->pid);
+#ifdef HAVE_GROUP_MEMBERS
+      flags = spin_lock_irqsave_wo_note(NULL);

Review Comment:
   spin_lock_irqsave



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to