Get the latest tech news

Introduction to Golang Preemption Mechanisms


A short explanation of what is preemption and how it works

So a goroutine could suck up all the cpu-time, starve the others, and delay new ones, until it explicitly gave up control, such as by calling runtime.Gosched() or during I/O operations. It occurs at so-called “safe-points”, which are places in the code where we know for sure that we can take over control flow from a goroutine without getting into trouble. As said in the comments, asyncPreempt spills all registers to save the context, and gets into asyncPreempt2, which in turn goes into gopreempt_m, that will act as if the goroutine just called runtime.Gosched().

Get the Android app

Or read this on Hacker News

Read more on:

Photo of introduction

introduction

Related news:

News photo

Introduction to Kubernetes (k8) – a quick lookback

News photo

Full Introduction to Golang with Test-Driven Development

News photo

Introduction to Linear Algebra