liveBook · Manning

Real-time clock

As explained in Rust in Action: Systems programming concepts and techniques

A real-time clock is a hardware clock that maintains calendar time independently of the main processor and usually continues running while the system is powered off.

A real-time clock (RTC), also called a CMOS clock, is a battery-powered hardware clock embedded in a computer’s motherboard. It maintains calendar time while the computer is powered off. When the system boots, the operating system takes over timekeeping from the RTC and exposes system time to applications. section 9.1 section 9.3

Distinguish the RTC from other clocks in a computer:

  • The real-time clock preserves calendar time while power is off. section 9.3
  • The system clock is the operating system’s view of time and can jump when manually adjusted. section 9.3
  • A steady clock is better for measuring durations because it increases monotonically, but it does not represent calendar time. section 9.3

Adding an RTC to a Raspberry Pi

A Raspberry Pi lacks a battery-supported real-time clock. Without network access, it starts with epoch time and cannot reliably timestamp data. The Cacophony Project added a Raspberry Pi Hat containing an RTC to its thermal-imaging device, allowing recorded footage to receive accurate timestamps offline. section 9.1

Inspect the prototype hardware that combines the Raspberry Pi with an additional real-time clock. section 9.1

How Rust in Action: Systems programming concepts and techniques covers it

How deep it goes
Explains hardware, power-off behavior, boot handoff, and clock distinctions, but stops short of detailed circuit implementation.
Examples
Uses a Raspberry Pi without an RTC and the Cacophony Project’s added Raspberry Pi Hat as concrete hardware examples.
What you can do after
Evaluate/understand when hardware-backed timekeeping is needed for reliable timestamps across shutdowns and network outages.
How it connects
Connects real-time clocks with system clocks, system time, NTP, epoch time, and steady clocks.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust in Action: Systems programming concepts and techniques. The section links point to the parts of the book it draws on.