From 3f8a110e4a2d131f0a13dd3c811cd74102345060 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Mon, 7 Apr 2025 10:09:29 +0200 Subject: [PATCH] runtime: move mainExited boolean This variable is only necessary on the cooperative and none scheduler. It is not used on the threads scheduler. The reason for moving is that the upcoming multicore baremetal scheduler also needs mainExited but of a different type: an atomic variable instead of a plain boolean. --- src/runtime/scheduler.go | 2 -- src/runtime/scheduler_cooperative.go | 3 +++ src/runtime/scheduler_none.go | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/runtime/scheduler.go b/src/runtime/scheduler.go index d3d61f48e..9ca54e1c0 100644 --- a/src/runtime/scheduler.go +++ b/src/runtime/scheduler.go @@ -4,8 +4,6 @@ import "internal/task" const schedulerDebug = false -var mainExited bool - var timerQueue *timerNode // Simple logging, for debugging. diff --git a/src/runtime/scheduler_cooperative.go b/src/runtime/scheduler_cooperative.go index 3cd8001c0..82ec24bee 100644 --- a/src/runtime/scheduler_cooperative.go +++ b/src/runtime/scheduler_cooperative.go @@ -27,6 +27,9 @@ const hasScheduler = true // concurrency, it does not have parallelism. const hasParallelism = false +// Set to true after main.main returns. +var mainExited bool + // Queues used by the scheduler. var ( runqueue task.Queue diff --git a/src/runtime/scheduler_none.go b/src/runtime/scheduler_none.go index 25bd7eb9c..82e720393 100644 --- a/src/runtime/scheduler_none.go +++ b/src/runtime/scheduler_none.go @@ -9,6 +9,9 @@ const hasScheduler = false // No goroutines are allowed, so there's no parallelism anywhere. const hasParallelism = false +// Set to true after main.main returns. +var mainExited bool + // run is called by the program entry point to execute the go program. // With the "none" scheduler, init and the main function are invoked directly. func run() {