Skip to content

runtime: ensure time.Sleep(d) sleeps at least d #4957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions builder/sizes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func TestBinarySize(t *testing.T) {
// This is a small number of very diverse targets that we want to test.
tests := []sizeTest{
// microcontrollers
{"hifive1b", "examples/echo", 4556, 280, 0, 2264},
{"microbit", "examples/serial", 2920, 388, 8, 2272},
{"wioterminal", "examples/pininterrupt", 7379, 1489, 116, 6912},
{"hifive1b", "examples/echo", 4580, 280, 0, 2264},
{"microbit", "examples/serial", 2928, 388, 8, 2272},
{"wioterminal", "examples/pininterrupt", 7387, 1489, 116, 6912},

// TODO: also check wasm. Right now this is difficult, because
// wasm binaries are run through wasm-opt and therefore the
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/scheduler_cooperative.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ func addSleepTask(t *task.Task, duration timeUnit) {
panic("runtime: addSleepTask: expected next task to be nil")
}
}
t.Data = uint64(duration)
now := ticks()
if sleepQueue == nil {
scheduleLog(" -> sleep new queue")

// set new base time
sleepQueueBaseTime = now
}
t.Data = uint64(duration + (now - sleepQueueBaseTime))

// Add to sleep queue.
q := &sleepQueue
Expand Down
Loading