+void *Periodic_Thread(void *Unused __attribute__((unused)))
+{
+ int i;
+
+ for( ;; )
+ {
+ sleep(10); // Sleep for a while
+// printf("Periodic firing\n");
+ for( i = 0; i < ciMaxPeriodics; i ++ )
+ {
+ if( gaPeriodicCalls[i].Function )
+ gaPeriodicCalls[i].Function();
+ }
+ }
+ return NULL;
+}
+
+void StartPeriodicThread(void)
+{
+ pthread_create( &gTimerThread, NULL, Periodic_Thread, NULL );
+}
+
+void AddPeriodicFunction(void (*Fcn)(void))
+{
+ int i;
+ for( i = 0; i < ciMaxPeriodics; i ++ )
+ {
+ if( gaPeriodicCalls[i].Function ) continue;
+ gaPeriodicCalls[i].Function = Fcn;
+ return ;
+ }
+
+ fprintf(stderr, "Error: No space for %p in periodic list\n", Fcn);
+}
+