cederom commented on PR #4026: URL: https://github.com/apache/nuttx-apps/pull/4026#issuecomment-7206637586
Thank you @u7k4rs6 :-) * **The "racing" case probably doesn't race.** Both threads run `mutex_thread_func()`. On a single core, thread 1 will almost always lock first and finish the lazy init before thread 2 calls lock, so the concurrent init path is not exercised. Starting both threads on a `pthread_barrier_t` right before the first `pthread_mutex_lock()` would give a real race, at least on `sim:smp`. If you keep it as it is, please reword the comment so it doesn't overclaim. * **Unchecked unlock.** The return value of `pthread_mutex_unlock()` after the zero-filled trylock is ignored. Please check it, since it is the first unlock of a lazily initialized mutex. * Optional: also do a single-threaded `pthread_mutex_lock()`/`pthread_mutex_timedlock()` on a freshly zeroed mutex. Today only trylock and the threaded path cover lock, and the threaded path covers it indirectly. Once nuttx#21719 also handles unlock, a "zero-filled, never locked, unlock" case could test that too (in configs where it should return EPERM). -- 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]
