aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/runtime/scheduler_none.go
blob: 7775b360eb0de16c98a171d26cce66e112a320f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//go:build scheduler.none

package runtime

import "internal/task"

const hasScheduler = false

// 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() {
	initHeap()
	initAll()
	callMain()
	mainExited = true
}

//go:linkname sleep time.Sleep
func sleep(duration int64) {
	if duration <= 0 {
		return
	}

	sleepTicks(nanosecondsToTicks(duration))
}

func deadlock() {
	// The only goroutine available is deadlocked.
	runtimePanic("all goroutines are asleep - deadlock!")
}

func scheduleTask(t *task.Task) {
	// Pause() will panic, so this should not be reachable.
}

func Gosched() {
	// There are no other goroutines, so there's nothing to schedule.
}

func addTimer(tim *timerNode) {
	runtimePanic("timers not supported without a scheduler")
}

func removeTimer(tim *timer) bool {
	runtimePanic("timers not supported without a scheduler")
	return false
}

func schedulerRunQueue() *task.Queue {
	// This function is not actually used, it is only called when hasScheduler
	// is true.
	runtimePanic("unreachable: no runqueue without a scheduler")
	return nil
}

func scheduler(returnAtDeadlock bool) {
	// The scheduler should never be run when using -scheduler=none. Meaning,
	// this code should be unreachable.
	runtimePanic("unreachable: scheduler must not be called with the 'none' scheduler")
}

// getSystemStackPointer returns the current stack pointer of the system stack.
// This is always the current stack pointer.
func getSystemStackPointer() uintptr {
	return getCurrentStackPointer()
}