reorganized limited semaphore wait and post functions
fixed limited semaphore callback to allow returning structures