# Thread Synchronization

- ## Semaphores

  - Named vs. Unnamed
  - Part of POSIX.1b, but not Pthreads
  - More expensive
  - int sem_wait(sem_t *sem); (Dijkstra’s P),
  - int sem_post(sem_t *sem); (V)

- ## Read-Write Locks (X/Open extension)

  - Allows multiple simultaneous reads, serial writes
  - int pthread_rwlock_rdlock(pthread_rwlock_t *rw);
  - int pthread_rwlock_wrlock(pthread_rwlock_t *rw);
  - int pthread_rwlock_unlock(pthread_rwlock_t *rw);
  - Reader Preference, Writer Preference, Equal Preference

Previous slide | Next slide | Back to first slide | View graphic version