Skip to content

clock_settime

Intro

clock_settime - Used to set the time of the specified clock

Description

The clock_settime() system call sets the time of the specified clock, clk_id, to the broken-down time, *tp.

If clk_id is CLOCK_REALTIME or CLOCK_MONOTONIC, the time values tp is interpreted as a time value relative to the Epoch, satisfying the constraint that the Epoch + the seconds field in the tp structure must not exceed the maximum value supported by the kernel.

The clock can be adjusted with respect to another clock, which is specified by the clockid argument. It is also possible to set a processor-specific clock with the types of CLOCK_PROCESS_CPUTIME_ID or CLOCK_THREAD_CPUTIME_ID.

Using CLOCK_REALTIME, CLOCK_MONOTONIC, or CLOCK_REALTIME_COARSE will guarantee a representable time, satisfying the constraint mentioned above.

Arguments

  • clockid: const clockid_t - Identifies a particular clock. The supported clocks depends on the implementation.
  • tp: const struct timespec * - Pointer to a timespec structure that contains the new time.

Available Tags

  • K - Originated from kernel-space.
  • U - Originated from user space (for example, pointer to user space memory used to get it)

Hooks

do_sys_clock_settime

Type

Kprobe

Purpose

To monitor and record the time setting events.

Example Use Case

The clock_settime() system call can be used to set the clocks of real-time applications with an accuracy of around one microsecond. It is useful for ensuring events are accurately timed and synchronized.

Issues

If the specified clock id is invalid, the kernel will return an invalid argument error.

  • 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.