On Sun, Jan 31, 2021 at 7:07 PM robert engels <reng...@ix.netcom.com> wrote:
>
> Not sure the runtime needs it - as all lock usages are known - so the users 
> in the runtime can ’negotiate’ fairness through other means for a particular 
> mutex.

Yes.  The point of starvation mode in sync.Mutex is to avoid high tail
latency for highly contended mutexes, in which one set of goroutines
acquiring the mutex can starve a different set of goroutines waiting
for the mutex.  The runtime does not have highly contended mutexes.
When we discover a highly contended mutex in the runtime, we change
the code to use a different approach.

That is, sync.Mutex has to work reasonably well for any Go program.
The runtime.mutex type only has to work well for the runtime package.

Ian


> On Jan 31, 2021, at 8:56 PM, xie cui <cuiwei...@gmail.com> wrote:
>
> mutex in sync package and runtime is different,
> mutex in runtime package is here, 
> https://github.com/golang/go/blob/master/src/runtime/lock_futex.go#L46
> i do not see there is a starving mode.
>
> On Monday, February 1, 2021 at 12:38:08 AM UTC+8 jake...@gmail.com wrote:
>>
>> What makes you think it does not? Have you looked at Mutex.lockSlow()? I 
>> have not really worked through the algorithm, but the comments do mention 
>> starvation mode.
>>
>> On Sunday, January 31, 2021 at 10:15:23 AM UTC-5 cuiw...@gmail.com wrote:
>>>
>>> why mutex in runtime do not need starve mode?
>
>
> --
> 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/0cc1fae8-6c22-4e40-9645-425d12bb909dn%40googlegroups.com.
>
>
> --
> 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/E5ADD213-563A-4F32-9467-3F9FC82EDF38%40ix.netcom.com.

-- 
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/CAOyqgcWd8map%3DOSRhhibz2nF2G-Rg4nXZLEwt%2BRrGEOjULDXvw%40mail.gmail.com.

Reply via email to