471,585 Members | 1,594 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,585 software developers and data experts.

wait in c

hi!! Is there a function in order to wait for a time in milliseconds??
Thanks in advance

Jan 13 '06 #1
4 46630

"Pierpaolo" <pi*******@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
hi!! Is there a function in order to wait for a time in milliseconds??


See FAQ, Question 19.37
Jan 13 '06 #2
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 '06 #3
th***********@gmx.at 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) ks***@mib.org <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.
Jan 14 '06 #4
th***********@gmx.at 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
Jan 15 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Danny Masti | last post: by
2 posts views Thread by Rasmus Grøndahl Olsen | last post: by
22 posts views Thread by codefixer | last post: by
15 posts views Thread by Snuyt | last post: by
12 posts views Thread by Perecli Manole | last post: by
22 posts views Thread by Jason Zheng | last post: by
2 posts views Thread by greyradio | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.