Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/runtime/scheduler_cores.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,6 @@ func run() {

func scheduler(_ bool) {
for mainExited.Load() == 0 {
// Check for ready-to-run tasks.
if runnable := runqueue.Pop(); runnable != nil {
// Resume it now.
setCurrentTask(runnable)
runnable.RunState = task.RunStateRunning
schedulerLock.Unlock() // unlock before resuming, Pause() will lock again
runnable.Resume()
setCurrentTask(nil)

continue
}

var now timeUnit
if sleepQueue != nil || timerQueue != nil {
now = ticks()
Expand Down Expand Up @@ -253,6 +241,18 @@ func scheduler(_ bool) {
}
}

// Check for ready-to-run tasks.
if runnable := runqueue.Pop(); runnable != nil {
// Resume it now.
setCurrentTask(runnable)
runnable.RunState = task.RunStateRunning
schedulerLock.Unlock() // unlock before resuming, Pause() will lock again
runnable.Resume()
setCurrentTask(nil)

continue
}

// At this point, there are no runnable tasks anymore.
// If another core is using the clock, let it handle the sleep queue.
if hasSleepingCore() {
Expand Down
Loading