Skip to main content

Practice ยท 3 of 4

rwlock with a Live Reader Count

CHALLENGE
Difficulty: advanced+25 XP

Given: a pthread_rwlock_t and int active_readers. Implement void lock_read(void) (rdlock AND increment active_readers), void unlock_read(void) (decrement, then unlock), void lock_write(void) / void unlock_write(void) wrapping wrlock. The metric is how tests observe concurrency โ€” keep it truthful.

Back to lesson: Practice: Synchronization Drills