Instead of waiting 1e6/hw.freq microseconds, sleep 1e9/hw.freq nanoseconds and adjust for the time required for obtaining and analysing a pulse. The idea is to bring the actual number of samples closer to hw.freq but it makes little difference in practice on my Raspberry Pi (700 MHz, clang -O, FreeBSD 10.0-ALPHA4).
Instead of waiting 1e6/hw.freq microseconds, sleep 1e9/hw.freq nanoseconds
and adjust for the time required for obtaining and analysing a pulse.
The idea is to bring the actual number of samples closer to hw.freq but
it makes little difference in practice on my Raspberry Pi (700 MHz,
clang -O, FreeBSD 10.0-ALPHA4).

nanosleep() can return the amount of unslept time in case it got
interrupted, usleep() can not.

rene0/dcf77pi,rene0/dcf77pi