Questions for source code of sync.mutex

Source Code: - The Go Programming Language

  1. In line 174, why check !starving first? Once we have already statisfied line 165 old&mutexStarving != 0 , starving always is true. Is not it?

  2. Could someone explain the comment btw line 177-179? What does two goroutines can go lock-step infinitely once they switch mutex to starvation mode mean?

Appreciate any help~

mutex has two states: nornal states and starving states,the translation beteen two states avoid a goroutine hold mutex long time.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.