switched places of signalling semaphore and context restoring