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


##########
sched/pthread/pthread_condbroadcast.c:
##########
@@ -68,9 +67,13 @@ int pthread_cond_broadcast(FAR pthread_cond_t *cond)
     }
   else
     {
+      int wcnt = atomic_read((FAR atomic_t *)&cond->wait_count);
+
       /* Loop until all of the waiting threads have been restarted. */
 
-      while (cond->wait_count > 0)
+      while (wcnt && atomic_cmpxchg((FAR atomic_t *)&cond->wait_count,

Review Comment:
   remove the cast



##########
sched/pthread/pthread_condclockwait.c:
##########
@@ -113,7 +114,7 @@ int pthread_cond_clockwait(FAR pthread_cond_t *cond,
 
       sinfo("Give up mutex...\n");
 
-      cond->wait_count++;
+      atomic_fetch_add((FAR atomic_t *)&cond->wait_count, 1);
 

Review Comment:
   ditto



##########
include/pthread.h:
##########
@@ -269,7 +269,7 @@ struct pthread_cond_s
 {
   sem_t sem;
   clockid_t clockid;
-  uint16_t wait_count;
+  unsigned int wait_count;

Review Comment:
   let's change to atomic_t



-- 
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: commits-unsubscr...@nuttx.apache.org

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

Reply via email to