wait in c

Discussion in 'C Programming' started by Pierpaolo, Jan 13, 2006.

  1. Pierpaolo

    Pierpaolo Guest

    hi!! Is there a function in order to wait for a time in milliseconds??
    Thanks in advance
    Pierpaolo, Jan 13, 2006
    #1
    1. Advertising

  2. Pierpaolo

    pemo Guest

    "Pierpaolo" <> wrote in message
    news:...
    > hi!! Is there a function in order to wait for a time in milliseconds??


    See FAQ, Question 19.37
    pemo, Jan 13, 2006
    #2
    1. Advertising

  3. Pierpaolo

    Guest

    Hello

    There is no wait_milliseconds() or wait_mycroseconds() function
    in the C library or under UNIX/Linux. Windows has the Sleep()
    function to wait for milliseconds, but it is not very precise.

    Under UNIX/Linux there are signals and the setitimer() function
    can be called to issue a signal after an amount of time measured
    in seconds and mycroseconds.

    If you want to see how this is programmed, look at Seed7
    (http://seed7.sourceforge.net).

    In the file seed7/src/tim_unx.c (found in seed7_05_20060111.tgz
    or a newer version) you find the Seed7 time driver.

    The function await_time() uses signals (with sigaction(),
    sigsetjmp() and setitimer() or signal(), setjmp() and setitimer() )
    to wait for a duration expressed in seconds and mycroseconds.

    The whole await_time() function waits for a time (not a duration)
    expressed in seconds and mycroseconds. This allows Seed7
    to have an await() function which can wait for very small
    durations. The example program panic.sd7 waits in 30
    millisecond intervals to show a smooth motion of the monsters.

    I hope this can help you

    Greetings Thomas Mertes

    Seed7 Homepage: http://seed7.sourceforge.net
    Wikipedia: http://en.wikipedia.org/wiki/Seed7
    Project page: http://sourceforge.net/projects/seed7
    , Jan 14, 2006
    #3
  4. writes:
    > There is no wait_milliseconds() or wait_mycroseconds() function
    > in the C library or under UNIX/Linux. Windows has the Sleep()
    > function to wait for milliseconds, but it is not very precise.


    There is no wait function of any kind in standard C. UNIX/Linux
    solutions can be discussed in comp.unix.programmer; Windows solutions
    can be discussed in a Windows group, perhaps
    comp.os.ms-windows.programmer.win32. Both of those groups are full of
    experts who know far more about these solutions than we do here. (In
    some cases, they may be the same people.)

    The C FAQ covers this issue in question 19.37, including pointers to
    system-specific functions that the OP can investigate further.

    Going into a lot of detail about system-specific features is generally
    discouraged here, for a number of reasons that I won't go into.

    Finally, it's important to provide some context when you post a
    followup. Please read <http://cfaj.freeshell.org/google/>.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Jan 14, 2006
    #4
  5. Pierpaolo

    Logan Shaw Guest

    wrote:
    > There is no wait_milliseconds() or wait_mycroseconds() function
    > in the C library or under UNIX/Linux.


    On most Unix systems, there is always this approach:

    select(0, NULL, NULL, NULL, & my_timeval_struct);

    - Logan
    Logan Shaw, Jan 15, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Taras Pich

    Wait for MS Project to close

    Taras Pich, Apr 19, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    2,467
    Taras Pich
    Apr 30, 2004
  2. VHDL User

    Wait on...

    VHDL User, Aug 26, 2004, in forum: VHDL
    Replies:
    2
    Views:
    3,028
    Edmond Cote
    Aug 30, 2004
  3. Roman
    Replies:
    2
    Views:
    6,325
    vipinlal
    Mar 4, 2010
  4. Brad Smallridge

    wait until

    Brad Smallridge, Mar 23, 2005, in forum: VHDL
    Replies:
    2
    Views:
    599
    info_
    Mar 26, 2005
  5. Huey

    How to make "fork/wait" to WAIT longer?

    Huey, Mar 1, 2004, in forum: C Programming
    Replies:
    1
    Views:
    1,931
    -berlin.de
    Mar 1, 2004
Loading...

Share This Page