1. A "pulse writing" thread writes a pulse to the file when it receives a semaphore signal. 2. Time::HiRes clock_nanosleep (or similar) runs in the main thread sending a signal precisely every 500msec to the "pulse writing" thread.