If I have multiple threads all waiting on the same semaphore (the semaphores being in shared memory), is there any rule as to which gets allowed to run first when that semaphore is queued?
My guess to this answer would be no; that the thread which gets to pass on the one queue signal would be whichever thread is "lucky" enough to get it's CPU time first after the semaphore is signaled/queued.
If this is the case, is there any way to specify that you'd like the order of precedence to be the order in which they arrived?