Implementation of read/write lock using Pthread API