Skip to content

Commit e2a2133

Browse files
hujun260xiaoxiang781216
authored andcommitted
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 <hujun5@xiaomi.com>
1 parent eec957a commit e2a2133

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

testing/ostest/pthread_rwlock.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ static FAR void *race_cond_thread1(FAR void *data)
8888
ASSERT(false);
8989
}
9090

91+
sem_wait(rc->sem1);
9192
status = pthread_rwlock_rdlock(rc->rw_lock);
9293
if (status != 0)
9394
{
@@ -197,6 +198,7 @@ static FAR void *race_cond_thread2(FAR void *data)
197198
ASSERT(false);
198199
}
199200

201+
sem_post(rc->sem1);
200202
if (g_race_cond_thread_pos++ != 3)
201203
{
202204
printf("pthread_rwlock: Thread order unexpected. Expected 3, got %d",

0 commit comments

Comments
 (0)