interupt simulation

Silcrome's Avatar, Join Date: Jul 2008
Go4Expert Member
Hey, I'm writing a program this time that will indefinately run a loop but i want it to pause at the end of teh loop so that the loop starts when it gets a signal at every 50ms(or some other arbitrary time). I wanted to do this an interupt b/c it will eventually go on hardware that will send an interupt that will set a value. Also doing this should free the processor for other stuff to go on in the background while it runs and cannot use sleep(). Anyone know a way to do this in C that wouldn't too overcomplicated b/c it will all be thrown out eventually and would just be for testing.

thanks,

-silcrome
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
you could drop into a sleep/check the clock loop and continue only when 50ms (minus the loop execution time) has passed. This is OS/compiler specific though; there's no way in standard C to do this, so what platform and compiler are you using?
0
Silcrome's Avatar, Join Date: Jul 2008
Go4Expert Member
i am compiling in gcc on a unix box running SunOS 5.6 the main problem im running into is that the implementation of sleep() ive noticed doesn't give control of the processor to another thread but only to other processes in the OS.