Re: pps_capture() and pps_fetch()

From: Poul-Henning Kamp <phk_at_phk.freebsd.dk>
Date: Wed, 01 Jun 2022 07:25:14 UTC
--------
Sebastian Huber writes:

> I try to understand how the PPS synchronization works in FreeBSD. It 
> seems that pps_capture() starts a transaction and pps_event() completes 
> the transaction if nothing interfered in the meantime.

The answer to most of your questions are in ./i386/i386/elan-mmcr.c

The PPS capture in the Soekris 4501 used two hardware counters, counting at the same rate.

The first of the two were the timecounter, the other was started by the hardware signal.

Sometime later the hardware signals interrupt processing would happen.

By reading read both counters as close to instantaneously as possible, and compensated for the interrupt latency by subtracting the event-started counter from the timecounter.

(See also: http://phk.freebsd.dk/soekris/pps/)

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.