mercredi 31 janvier 2018

Lot of threads waiting for a mutex

The following situation occured in some code I found. A lot (about 10) of threads use one mutex to write or read from a map. The mutex locking is done with a lock_guard. My question is about the situation where the thread number increased and 10 threads are waiting at the same time for the mutex. I know that there is no guarantee on the order. Are there any side effects on this situation? Is there at least a guarantee that every thread is able to lock the mutex or may there be threads that never get a chance to access the data structure because others are faster?

Aucun commentaire:

Enregistrer un commentaire