Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   interupt simulation (http://www.go4expert.com/forums/interupt-simulation-t12888/)

Silcrome 12Aug2008 21:44

interupt simulation
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.



xpi0t0s 17Aug2008 03:52

Re: interupt simulation
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?

Silcrome 18Aug2008 18:21

Re: interupt simulation
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.

All times are GMT +5.5. The time now is 17:39.