You are using and modifying pool->waiting_in_queue but where are you assigning it an initial value?
pool->waiting_in_queue
Also if sdm_threadpool and the other types like it are custom structures please include the definition of those structures.
sdm_threadpool