Skip to content

Undesirable behaviour of z_clock_announce() when ticks argument is greater by 1 #12332

@pizi-nordic

Description

@pizi-nordic

The z_clock_announce() unconditionally adjust dticks of first timeout in the list:

if (first() != NULL) {
	first()->dticks -= announce_remaining;
}

However this adjustment is not always valid:

  1. If the adjusted timeout was on the list before call to z_clock_announce(), we have to do such correction in order to not delay next timeout.

  2. If the adjusted timeout belongs to periodic k_timer which was handled during current z_clock_announce() execution, we should do such correction if we would like to not accumulate error.

  3. If the adjusted timeout was added during current z_clock_announce() execution but it is not related periodic timer which was handled, we have to skip the adjustment. If we perform it, the newly scheduled timeout will fire earlier than expected.

This issue has been initially mentioned in #11722.
Affected use case is presented here: #12247 (comment)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions