In sync/mutex.go, there is a comment like the following: ```go // Mutex fairness. // // Mutex can be in 2 modes of operations: normal and starvation. // In normal mode waiters are queued in FIFO order, but a woken up waiter // does not own the mutex and competes with new arriving goroutines over // the ownership. New arriving goroutines have an advantage -- they are // already running on CPU and there can be lots of them, so a woken up // waiter has good chances of losing. In such case it is queued at front // of the wait queue. If a waiter fails to acquire the mutex for more than 1ms, // it switches mutex to the starvation mode. ```
I wonder if the waiter here refers to the goroutine at the head of the queue, or any goroutine in the queue? If any goroutine in the queue causes the lock to enter starvation mode, but the next goroutine that acquires the lock immediately is not it but the one at the head of the queue, whether it is better to change it to who makes the lock enter starvation mode and who immediately acquires the lock ? Thanks for discussion and answers. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/96be0e99-8631-4f4e-adc9-092e309585d8n%40googlegroups.com.