Rewrote semaphores

We now use statically allocated data and local descriptors.