1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

interupt simulation

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

  1. Silcrome

    Silcrome New Member

    Joined:
    Jul 28, 2008
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Software Engineer
    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
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    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

    Joined:
    Jul 28, 2008
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Software Engineer
    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