mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 23:13:40 +00:00
runtime: prevent timer starvation in cores scheduler
This commit is contained in:
@@ -195,18 +195,6 @@ func run() {
|
|||||||
|
|
||||||
func scheduler(_ bool) {
|
func scheduler(_ bool) {
|
||||||
for mainExited.Load() == 0 {
|
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
|
var now timeUnit
|
||||||
if sleepQueue != nil || timerQueue != nil {
|
if sleepQueue != nil || timerQueue != nil {
|
||||||
now = ticks()
|
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.
|
// At this point, there are no runnable tasks anymore.
|
||||||
// If another core is using the clock, let it handle the sleep queue.
|
// If another core is using the clock, let it handle the sleep queue.
|
||||||
if hasSleepingCore() {
|
if hasSleepingCore() {
|
||||||
|
|||||||
Reference in New Issue
Block a user