1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

interupt simulation

Discussion in 'C' started by Silcrome, Aug 12, 2008.

  1. Silcrome

    Silcrome New 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.


  2. xpi0t0s

    xpi0t0s 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?
  3. Silcrome

    Silcrome New 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.

Share This Page