#include <stdio.h>
#include <time.h>
+long const pulsewidth = 250000000; /* nanoseconds */
+
static void
pulse()
{
+ struct timespec const ts = { 0, pulsewidth };
/* Dummy implementation */
- printf("tick!\n");
+ printf("ker...");
+ fflush(stdout);
+ clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, NULL);
+ printf("chunk!\n");
}
static void
ts.tv_nsec = 0;
ts.tv_sec -= tm.tm_sec % 30;
/* Choose when next tick will be. */
- ts.tv_sec += 30;
+ ts.tv_nsec = 1000000000 - pulsewidth;
+ ts.tv_sec += 29;
if (clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &ts, NULL)
!= 0)
err(1, "clock_nanosleep");