# Timer Slack

[Timer objects](https://fuchsia.dev/docs/reference/kernel_objects/timer) have a concept of slack. Slack
defines how the system may alter the timer's deadline. Slack allows
the system to internally coalesce timers and timer-like events to
improve performance or efficiency.

Slack is made up of two components, type and amount. Type describes
how slack can be applied:

- **ZX_TIMER_SLACK_CENTER** coalescing is allowed with earlier and later timers.
- **ZX_TIMER_SLACK_EARLY** coalescing is allowed only with earlier timers.
- **ZX_TIMER_SLACK_LATE** coalescing is allowed only with later timers.

Amount is the allowed deviation from the deadline. For example, a
timer with **ZX_TIMER_SLACK_EARLY** and 5us may fire up to 5us before
its deadline. A timer with **ZX_TIMER_SLACK_CENTER** and 7ms may fire
anywhere from 7ms before its deadline to 7ms after its deadline.

## Timer-like Syscalls

Slack may also be applied to blocking syscalls that accept a deadline
argument, like [`zx_nanosleep()`](https://fuchsia.dev/reference/syscalls/nanosleep).

## Defaults and Job Policy

For Timer objects, slack is specified when creating and setting
timers. For other syscalls that take a deadline, but no slack
parameters, the slack type and amount are specified by the job's
policy. See [`zx_job_set_policy()`](https://fuchsia.dev/reference/syscalls/job_set_policy).
[](https://issues.fuchsia.dev/issues/new?component=1439230&template=1881640&description=Issue+on:+https://fuchsia.dev/docs/concepts/kernel/timer_slack.md "Report a bug or suggest improvements on this page") [](https://cs.opensource.google/fuchsia/fuchsia/+/main:docs/concepts/kernel/timer_slack.md "View the source code of this page") [](https://ci.android.com/edit?repo=fuchsia/fuchsia/main&file=docs/concepts/kernel/timer_slack.md&cloneRepo=fuchsia/fuchsia:refs/heads/main&fullPath=fuchsia/docs/concepts/kernel/timer_slack.md "Edit the source code of this page")