473,557 Members | 2,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 46809

"Pierpaolo" <pi*******@gmai l.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
hi!! Is there a function in order to wait for a time in milliseconds??

See FAQ, Question 19.37
Jan 13 '06 #2

There is no wait_millisecon ds() or wait_mycrosecon ds() 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

In the file seed7/src/tim_unx.c (found in seed7_05_200601 11.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***********@g mx.at writes:
There is no wait_millisecon ds() or wait_mycrosecon ds() 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.progr ammer; Windows solutions
can be discussed in a Windows group, perhaps
comp.os.ms-windows.program mer.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_Keit h) 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***********@g mx.at wrote:
There is no wait_millisecon ds() or wait_mycrosecon ds() 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_stru ct);

- Logan
Jan 15 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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 gif - the gif shows up BUT it does not animate. How do I make the gif animate? THIS WORKS (initially hidden):-
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 suggestion? If I call the function like this: wait(500); it should wait 500ms right? function wait(time) { while(1){ setTimeout("break;",time); } }
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 the DB I am using a DIV with a please wait message which is removed once the page is loaded. In addition I am using a global error handling using...
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 everythign is declared */ time(&start); while ( childpid != wait(&status) )
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(), ManualResetEvent.Wait()) I’ll be able to take them out of the wait state even if the object which they are waiting on is not signaled (still blocking). ...
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...
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 block protecting a resource. Thread 2 and 3 also have a SyncLock block protecting the same resource and after executing some code in their blocks...
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 of code The database is a ODBC update database which is full automatic startup/shutdown but because i sometimes want to make som edits to it i want...
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 in my situation. I first created a few child processes with Popen, then in a while(True) loop wait on any of the child process to exit, then...
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 allows a commuter to pass easily while a cash booth creates a wait line. The wait line is expected to wait for the 5th commuter to pass before any...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.