from Hacker News

Ask HN: Can running goroutines directly read the updated value of writeBarrier?

by weiwenhao on 9/19/23, 8:38 AM with 0 comments

I am working on implementing a concurrent tri-color marking garbage collector. I read some posts that mention that prior to version 1.14, Golang could not forcibly stop goroutines, making it impossible to start GC. My question is, once the global variable runtime.writeBarrier is updated, wouldn't the running goroutines read the updated writeBarrier and activate the write barrier? Why is it necessary to wait for the goroutines to stop?

CMPL runtime.writeBarrier(SB), $0 JEQ 103 JMP 108