C ++ flags blocking priority

I want to give priority to a thread so that if two threads are waiting for a mutex, the thread with the highest priority will always accept the mutex to the lower priority.

A colleague suggested that by changing the thread priority of my thread, I should achieve this. I tried using a function SetThreadPriority()

to set one of the pending threads to 0 (normal) and the other to 2 (highest), but it doesn't affect the behavior of the mutex as I was hoping. The lock currently always goes to the first thread that requested ownership.

So is this normal behavior? Contrary to what my colleague thought? Is there any other way to specify the priority of a thread that may be missing? Or am I looking at a more complex problem to solve?

+3


source to share


1 answer


Thread priority indicates how much time a thread is getting on the CPU, as determined by the scheduler, which will preferentially assign higher priority threads - this does not affect the behavior of mutexes, and I am not aware of any means to create it does this.



+2


source







All Articles