V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
newmiao

Dig101-Go 之深入理解 mutex

  •  
  •   newmiao · Jul 5, 2020 · 1868 views
    This topic created in 2128 days ago, the information mentioned may be changed or developed.

    sync.MutexGo实现的互斥锁,提供了基本的同步操作,使用很方便。

    不过,你是否好奇过,Go是如何实现的Mutex,又是为什么要这样实现?

    今天跟随几个问题,我们一起探索下Mutex背后的设计。

    (不用担心,不会有大段的源码分析出现在本文😳)

    传送门: https://mp.weixin.qq.com/s/nTq_mYysUuY7YjCSVEubAQ


    推荐阅读:Dig101-Go 系列

    2 replies    2020-07-05 11:02:34 +08:00
    abbycin
        1
    abbycin  
       Jul 5, 2020 via Android   ❤️ 1
    我好奇过 mutex 的实现,然后看了 Linux 源码里面 mutex 的实现,然后发现只是加了 lock 指令前缀,完。
    newmiao
        2
    newmiao  
    OP
       Jul 5, 2020
    @abbycin 恩除此外,Go 有自己的用户态线程( goroutine )和 GMP 调度,所以可以在上层在做一些优化
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2561 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 12:34 · PVG 20:34 · LAX 05:34 · JFK 08:34
    ♥ Do have faith in what you're doing.