Go Mutex: User-space locking(futex) & Syscalls
overview
- Application level mutexes are basically atomic CAS in assembly on a global integer value
- Go leverages working of futex for optimising no-contention or low-contention scenarios.
- Why we need syscalls when we can just optimise at runtime scheduler by using gopark and goready ? Go routines can run on multiple OS threads, and incase there are not other go routines to run (all are blocked on an OS thread), we need to sleep the entire thread, this is where syscalls come in.
Content
TODO
resouces
- https://go.dev/src/runtime/proc.go (maybe ?)