<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Preemption on Shai Asher</title><link>https://slow-is-smooth.io/tags/preemption/</link><description>Recent content in Preemption on Shai Asher</description><generator>Hugo</generator><language>en-gb</language><lastBuildDate>Sun, 22 Mar 2020 09:00:00 +0200</lastBuildDate><atom:link href="https://slow-is-smooth.io/tags/preemption/index.xml" rel="self" type="application/rss+xml"/><item><title>Stopping a Goroutine Anywhere</title><link>https://slow-is-smooth.io/blog/stopping-a-goroutine-anywhere/</link><pubDate>Sun, 22 Mar 2020 09:00:00 +0200</pubDate><guid>https://slow-is-smooth.io/blog/stopping-a-goroutine-anywhere/</guid><description>&lt;p&gt;A Go 1.13 program starts a goroutine that runs a tight arithmetic loop for about a second, a loop that&#10;calls no functions. Then another goroutine asks for a garbage collection. The collection waits 1.1&#10;seconds before it can begin, and so does everything else in the program that needs the world stopped.&#10;On one processor it is worse: a goroutine that sleeps for 10 milliseconds wakes up 1.15 seconds later.&#10;The loop is doing nothing wrong. It simply never reaches a point where the runtime is able to ask it to&#10;stop. Go 1.14, released last month, changes that: the same collection now starts within a millisecond,&#10;because the runtime has learned to interrupt a goroutine at almost any instruction, by sending its&#10;thread a signal.&lt;/p&gt;</description></item></channel></rss>