The command byte 0x36 and divisor math you compute here (1193182 / frequency) is exactly what Linux's early boot code and hobby kernels like those documented on the OSDev wiki use to get a reliable scheduler tick before the APIC timer or HPET is available. Off-by-one divisor errors here are why some early bootloaders drift out of sync with wall-clock time over long uptimes.