This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new e2a21337a ostest/pthread_rwlock: We need to wait for race_cond_thread2
to acquire the rdlock first, otherwise it may cause a deadlock.
e2a21337a is described below
commit e2a21337ac5be663a8e6d9a82baa64b93cc19755
Author: hujun5 <[email protected]>
AuthorDate: Fri Nov 8 19:04:09 2024 +0800
ostest/pthread_rwlock: We need to wait for race_cond_thread2
to acquire the rdlock first, otherwise it may cause a deadlock.
Signed-off-by: hujun5 <[email protected]>
---
testing/ostest/pthread_rwlock.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/testing/ostest/pthread_rwlock.c b/testing/ostest/pthread_rwlock.c
index 860d94c84..67febadc1 100644
--- a/testing/ostest/pthread_rwlock.c
+++ b/testing/ostest/pthread_rwlock.c
@@ -88,6 +88,7 @@ static FAR void *race_cond_thread1(FAR void *data)
ASSERT(false);
}
+ sem_wait(rc->sem1);
status = pthread_rwlock_rdlock(rc->rw_lock);
if (status != 0)
{
@@ -197,6 +198,7 @@ static FAR void *race_cond_thread2(FAR void *data)
ASSERT(false);
}
+ sem_post(rc->sem1);
if (g_race_cond_thread_pos++ != 3)
{
printf("pthread_rwlock: Thread order unexpected. Expected 3, got %d",