Let a thread declare a lock (v. gr. std::unique_lock<std::mutex>
) to try to own a certain mutex. If contention, that thread will be added to a list of threads waiting for that mutex to be unlocked.
How long can that list get?
Considering that the actual length might differ between implementations, I'm just interested in knowing what is the order of magnitude. And if it is limited by stack size or memory?
While learning about mutexes and conditional variables, I figured that a particular implementation of a processing buffer could just generate a pool of threads with one lock per thread of the same mutex.
I understand that there is no actual limitation to the number of threads running simultaneously other than physical memory. So, is there, perhaps limitation in terms of the queue of threads waiting to acquire a single mutex?
I'm just curious. I'm not thinking of implementing this design... or maybe that is precisely why I should play with it and see its limitations, its "hackyness" and observe probably unforeseen problems with it. Is this a common design option?
Thank you,