#shared-memory #ntp #ec2 #aws #finite-state-machine

clock-bound-shm

A library used to interact with shared memory in ClockBound

1 stable release

1.0.0 Apr 9, 2024

#352 in Date and time

Download history 15/week @ 2024-07-28 7/week @ 2024-08-04 7/week @ 2024-08-11 16/week @ 2024-08-18 21/week @ 2024-08-25 12/week @ 2024-09-01 10/week @ 2024-09-08 29/week @ 2024-09-15 44/week @ 2024-09-22 36/week @ 2024-09-29 25/week @ 2024-10-06 36/week @ 2024-10-13 44/week @ 2024-10-20 36/week @ 2024-10-27 42/week @ 2024-11-03 8/week @ 2024-11-10

139 downloads per month
Used in 3 crates

Apache-2.0

68KB
879 lines

ClockBound Shared Memory

Overview

This crate implements the low-level IPC functionality to share ClockErrorBound data and clock status over a shared memory segment. It provides a reader and writer implementation to facilitate operating on the shared memory segment.

Clock status

Clock status are retrieved directly from chronyd tracking data.

  • Unknown: the status of the clock is unknown.
  • Synchronized: the clock is kept accurate by the synchronization daemon.
  • FreeRunning: the clock is free running and not updated by the synchronization daemon.

Finite State Machine (FSM)

FSM drives a change in the clock status word stored in the ClockBound shared memory segment. Each transition in the FSM is triggered by chrony. See following state diagram for clock status in shared memory:

State Diagram for ClockStatus in SHM

Errors returned by all low-level ClockBound APIs

  • SyscallError(Errno, &'static CStr): a system call failed.
    • variant includes the Errno struct with error details
    • an indication on the origin of the system call that error'ed.
  • SegmentNotInitialized: the shared memory segment is not initialized.
  • SegmentMalformed: the shared memory segment is initialized but malformed.
  • CausalityBreach: failed causality check when comparing timestamps.

Dependencies

~2–12MB
~80K SLoC