473,385 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 46800

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Danny Masti | last post by:
Hello, I have a HIDDEN div with a "Please Wait Message". OnSubmit I show the hidden div with the "Please Wait Message". It works fine. But if I replace the "Please Wait Message" with an animated...
2
by: Rasmus Grøndahl Olsen | last post by:
I have tried to write a wait function but it seems like it will not brake the while loop. I tried two different solutions. Can anyone tell me what I am doing wrong, and come with another...
0
by: s_erez | last post by:
Hi, This is a realy tricky one. I have an ASP.NET application where some pages are reading data from a DB and presenting reports. In order for the user to wait while the page is reading data from...
22
by: codefixer | last post by:
Hi, I have a situation where I have to handle the following scenario. The main() must wait for child to complete or the main() must kill the child after 3 seconds and exit. /* Assume...
4
by: Sharon | last post by:
I wish to control other threads, that are warped with my own classes, so when they are in any wait state (lock(), Monitor.Wait(), ReadWriteLock.Wait(), Mutex.Wait(), AutoResetEvent.Wait(),...
15
by: Snuyt | last post by:
Hello, I want the program to wait a few seconds between executing code. It should look something like this: public sub xx() ...code... wait(2) 'wait 2 seconds ...code...
12
by: Perecli Manole | last post by:
I am having some strange thread synchronization problems that require me to better understand the intricacies of Monitor.Wait/Pulse. I have 3 threads. Thread 1 does a Monitor.Wait in a SyncLock...
4
by: MrDeej | last post by:
Hello guys! I am trying to use trevors wait function on my odbc database for a countdown function. But this function is not stable as it sometimes dosent actually wait before launching next line...
22
by: Jason Zheng | last post by:
This may be a silly question but is possible for os.wait() to lose track of child processes? I'm running Python 2.4.4 on Linux kernel 2.6.20 (i686), gcc4.1.1, and glibc-2.5. Here's what happened...
2
by: greyradio | last post by:
I've recently have been given an assignment to do and it seems that notify() does notify() any of the waiting threads. The project entails 10 commuters and two different toll booths. The EZPass booth...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.