pussuw commented on code in PR #15566:
URL: https://github.com/apache/nuttx/pull/15566#discussion_r1917919515
##########
sched/pthread/pthread_condsignal.c:
##########
@@ -68,12 +66,16 @@ int pthread_cond_signal(FAR pthread_cond_t *cond)
}
else
{
- if (cond->wait_count > 0)
+ nxmutex_lock(&cond->mutex);
+
+ if (atomic_load(&cond->wait_count) > 0)
Review Comment:
Not strictly necessary here for the atomic_load(), we could just read the
counter, since reading a torn up value here has no impact (since we only
compare > 0). How would you do this with compare&exchange ?
In general, using atomic_xx operations with cond->wait_count removes the
need to use the mutex when incrementing cond->wait_count, since
atomic_fetch_add(&cond->wait_count, 1); ensures the read-modify-write to
cond->wait_count is atomic already.
--
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]