Skip to content

We should firm up the semantics of userlib::sleep* #206

Description

@cbiffle

So, we've kind of avoided dealing with the timebase problem. (Well, okay, mostly me.)

Currently we express time in all APIs as "system ticks," where the system tick is set for the application (board+image) to whatever you want .... but in practice is milliseconds. And basically all code assumes it's milliseconds.

There are two problems with this.

  1. We often need timing more precise than milliseconds, but changing the tick frequency, while easy, would break basically all drivers.
  2. The userlib time-related APIs don't actually do what you'd expect.

On that second point -- if you call sleep_for(1), you will (in the absence of higher priority tasks keeping you from being scheduled at all) sleep for somewhere between 0ms and 1ms. In other words, it's really sleep_for_at_most_ms. Often, we actually want at least.

The actual kernel time API is based on absolute deadlines rather than intervals (basically to keep the kernel out of this argument) so I think we could fix this part in userlib.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Triaged H2'26This issue or pull request has been triaged in the later half of 2026 as still relevant.developer-experienceFixing this would have a positive impact on developer experienceuserlibRelated to userlib, the fundamental library used by tasks

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions