I have a simple C app that uses constant 50%. I don’t know why but I like to minimize it as much as possible.
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
void Wait(int seconds)
{
clock_t endwait;
endwait = clock () + seconds * CLK_TCK ;
while (clock() < endwait) {}
}
void main()
{
printf ("program running.\n");
/* Wait( 4 ); */
printf( "Done Waiting!\n" );
printwow();
/* exit(0); */
}
timer_func (void)
{
Wait( 4 );
printwow();
}
printwow()
{
printf ("Say hello");
timer_func();
}
I guess it must be the timer of course. But I don’t know that for sure.
Thanks.
Use some built-in sleep function, that does not use processor cycles to “wait”, like
sleepfromunistd.h.