mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
runtime: prevent timer starvation in cores scheduler
This commit is contained in:
@@ -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()
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user