Skip to content

clock_adjtime64

Intro

clock_adjtime64 - Sets clock adjustment for a specific clock.

Description

The clock_adjtime64 function allows for an application to adjust the clock for a specific clock. The clock is specified by its id if the id is available. The new adjustment will be applied to the clock immediately if the clock is current, otherwise the adjustment is made relative to the present adjustment. The adjustment given consists of (1) a time value specifying when the adjustment should be made, and (2) a time value specifying the amount of time to be added or subtracted from the clock’s current time. The adjustment is always relative to the system time; that is, the adjustment represents the difference between the system time and the time to be set with the adjustment.

When an adjustment is applied, the clock’s ‘tick counter’ is reset to the adjusting ratio. This means that the number of clock ticks (or ‘tick counts’) since the last adjustment will remain fixed until the next adjustment.

The clock_adjtime64 function is useful for applications which require precise timing, like audio and video applications. Since the clock time is adjusted to the system time, applications can use this function to align their time-referenced activities with the system time.

However, applications must be aware of a few parameters when using clock_adjtime64. One is that if a change of the clock times is made, the process must also handle any updates to the system time. Another is that the adjustment may take longer than expected if the system clock is being heavily used.

Arguments

  • clock_id:__kernel_clockid_t[K] - The clock id of the clock to adjust. The clock id is a positive integer specifying the clock to modify.
  • ts:const struct __kernel_timespec *[K] - A pointer to a struct __kernel_timespec object containing the desired adjustment value (adjustmenttime) and the time of the adjustment (adjustmenttime).
  • old_ts:struct timespec *[K] - A pointer to a struct timespec object to receive the time of the last clock adjustment.

Available Tags

  • K - Originated from kernel-space.

Hooks

do_adjtimex

Type

Raw kernel probes

Purpose

Logging when clock_adjtime64 is called.

sys_clock_adjtime

Type

Kprobes

Purpose

Logging of clock_adjtime64 parameters.

Example Use Case

An audio software that uses clock_adjtime64 to keep a consistent clock time throughout the application. This provides a bulwark against timing issues that could otherwise lead to distortion or lost data.

Issues

Since the results of a successfully called clock_adjtime64 are non-deterministic, applications must handle the cases where the clock is determined to be too slow or too fast.

  • clock_settime
  • clock_gettime

This document was automatically generated by OpenAI and needs review. It might not be accurate and might contain errors. The authors of Tracee recommend that the user reads the "events.go" source file to understand the events and their arguments better.