Urgent.News

the world's headlines, one feed

Editions

Tech

Scheduling concurrency

Have been trying to look at 3 different languages: Go, Kotlin, Elixir/Erlang mostly to understand their concurrency models. This article concerns mostly about Go's preemptive scheduling. Looking at the dense article on go: https://go.googlesource.com/proposal/+/master/design/24543-non-cooperative-preemption.md Here is what I understand. Before Go 1.14: Cooperative preemption at function prologues…

This account explores the three programming languages Go, Kotlin, and Elixir/Erlang, with a focus on their concurrency models. The article delves into Go's preemptive scheduling, particularly in versions 1.14 and beyond.

Prior to Go 1.14, the language utilized cooperative preemption at function prologues. This method allowed the compiler to insert preemption points in those areas, ensuring precise garbage collection by knowing all local GC roots at safe-points. However, this approach had its drawbacks, such as the potential for a program to entirely halt in extreme cases and the introduction of a 7.8% slowdown in large benchmark suites despite efforts to mitigate the issue through fault-based preemption.

Go 1.14 introduced a signal-based non-cooperative preemption mechanism, which enabled switching between concurrent execution contexts without explicit preemption checks or assistance from those contexts. This change mirrors the way modern operating systems manage thread switching. When a goroutine is interrupted, the runtime captures its CPU state and resumes it later, eliminating the need for preemption checks.

The specific choice of the SIGURG signal for this purpose is explained. It meets several criteria, including passing through debuggers by default, not being used internally by libc in mixed Go/C binaries, being spurious and causing no harm, and being unlikely to be used by applications for its intended meaning. SIGUSR, on the other hand, is a different case, representing a more complex intersection of OS signals, compiler internals, runtime, and GC designs.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — it may contain errors, so check the original before relying on it.

Read the original at dev.to →

More in Tech

One Event-Loop Turn, One False Redis Capacity Error

This is a submission for DEV's Summer Bug Smash: Clear the Lineup powered by Sentry . Project Overview redis-py is the Python client for Redis.

  • Event loop race condition caused false Redis capacity error
  • Connection slot missing from in-use set and free queue
  • Fix ensures closed connections return to free queue immediately

🛻CSS Art: Smoothie Food Truck

This is a submission for Frontend Challenge - Comfort Food Edition, CSS Art . Inspiration 💠I was not sure I was going to enter this challenge at first, because I was not feeling inspired.