Giter Club home page Giter Club logo

Comments (1)

illicitonion avatar illicitonion commented on June 21, 2024

I've been thinking about the mutexes part of this, and I think we want to roughly cover:

  • A simple memory model (the idea we have registers, L1/L2 caches, and main memory), their rough speeds costs and limits, why we have these, and the fact that several of these are unsynchronised per-core, but without either teaching or assuming "here's all the parts of a CPU and how a whole OS works".
  • At a very high level, the concept of a memory barrier and a happens-before relationship.
  • Simple single-variable examples of thread unsafety (e.g. increment a counter from 100 goroutines, see it doesn't reliably end at 100). The idea that a mutex can fix this.
  • Multi-variable examples of thread unsafety - actually having to think about what the critical section is for a multi-statement operation, where atomics aren't sufficient (e.g. keeping a slice and a separate counter in sync or something to always have consistent views).
  • WaitGroup as a useful abstraction.
  • Channels as a useful way of signalling done-ness across goroutines (and passing data, I suppose).

I'm not sure which of these topics we care enough about to include (cc @sre-is-laura @Radha13 @nahratzah) :

  • Atomics, CompareAndSwap
  • Semaphores
  • RWMutex

I think the concurrency chapter of golangbot is a sufficient introduction to how to do most of these things in Go (i.e. the single-variable example, WaitGroups, Channels), and has sufficient examples for the single-variable stuff.

I have yet to find a good resource for explaining the ideas of tiered memory, barriers, and happens-before relationships that isn't either super vague and overly "here's how you write the code without knowing why", or super deep into much wider CPU and/or OS design. I'd be interested if anyone else can find one, otherwise we may need to put one together (@nahratzah @sre-is-laura do you know of any, or could you be tempted to write one? If not, I can try to put one together).

I can come up with an example exercise for thinking about the critical section when dealing with multiple variables.

from immersive-go-course.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.