Directory: Fix pattern matching issues on Linux
Semaphore: Add workaround for systems where sem_timedwait does not work