Start implementing semaphore-based mutex

Encapsulate type conversions involving _sem_t.