Semaphore and shared-mem fixes for OSX