anchao commented on code in PR #18009:
URL: https://github.com/apache/nuttx/pull/18009#discussion_r2706240796


##########
binfmt/binfmt_execmodule.c:
##########
@@ -123,9 +123,10 @@ static void exec_swap(FAR struct tcb_s *ptcb, FAR struct 
tcb_s *chtcb)
   chtcb->group->tg_children = ptcb->group->tg_children;
   ptcb->group->tg_children = tg_children;
 #  else
-  tg_nchildren = chtcb->group->tg_nchildren;
-  chtcb->group->tg_nchildren = ptcb->group->tg_nchildren;
-  ptcb->group->tg_nchildren = tg_nchildren;
+  nchildren = atomic_read(&chtcb->group->tg_nchildren);
+  atomic_set(&chtcb->group->tg_nchildren,
+             atomic_read(&ptcb->group->tg_nchildren));
+  atomic_set(&ptcb->group->tg_nchildren, nchildren);

Review Comment:
   I am skeptical about the effectiveness of this change. The race condition 
should occur in the code segments where the tg_nchildren variable is being 
used, rather than just performing atomic operations on it—such a modification 
will not have any effect at all.



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