I have a doubt about mutexes.
Global mutex;
/// more things
Acquire lock on mutex;
/// Do things here;
Release lock;
If a thread acquires the lock on the mutex(for example, a tbb mutex), can it be put to sleep by the processor while holding the lock and awaken later to finish the job, or when it gains the lock on the mutex it continue its work nonstop until releasing the lock?
Yes a thread holding a mutex can definitely be put to sleep and it probably will be put to sleep.
If you have a single core, then only one single thread can run at a single moment in time. If you have 10 threads running on a single core then 9 will be asleep at any one time.
Imagine what would happen if a thread with a mutex couldn’t be put to sleep, then only that one thread would run until the mutex is released. Your process would essentially become single threaded every time you take out a mutex even if the other nine threads don’t care about the thing the mutex is protecting.