473,469 Members | 1,826 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

millisecond delay in C - linux

Hi all,

does anyone know how to generate a millisecond delay in C, compiling
under Linux? I understand the function sleep() will generate a delay
down to a resolution of one second, but I need to be able to refine
this to milliseconds.

Any ideas?

Thanks in advance,

Ben.
Nov 14 '05 #1
8 46178
checkout the select() call - it is often used for such a purpose. or
nanosleep().

Macgyver wrote:
Hi all,

does anyone know how to generate a millisecond delay in C, compiling
under Linux? I understand the function sleep() will generate a delay
down to a resolution of one second, but I need to be able to refine
this to milliseconds.

Any ideas?

Thanks in advance,

Ben.

Nov 14 '05 #2
Robert Frunzke <Ro**************@freenet.de> scribbled the following:
checkout the select() call - it is often used for such a purpose. or
nanosleep().


Which part of the ISO C standard defines either of these functions?

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Ice cream sales somehow cause drownings: both happen in summer."
- Antti Voipio & Arto Wikla
Nov 14 '05 #3
"Macgyver" <bh******@dodo.com.au> wrote in message
news:63**************************@posting.google.c om...
does anyone know how to generate a millisecond delay in C, compiling
under Linux? I understand the function sleep() will generate a
delay down to a resolution of one second, but I need to be able to
refine this to milliseconds.


There is no way to do so in standard C, the topic of this newsgroup. The
function sleep() is also not part of standard C. The clue is the fact that
the operating system is relevant.

Try asking in comp.unix.programmer <OT> or man 2 nanosleep </OT>.

Note that you seem to be asking for a way to achieve your solution ("How do
I use a sledgehammer to crack a walnut?"), not for a solution to your
problem ("How do I crack a walnut?"). This may well mean you don't get the
best end result.
Nov 14 '05 #4

Joona I Palaste wrote:
Robert Frunzke <Ro**************@freenet.de> scribbled the following:
checkout the select() call - it is often used for such a purpose. or
nanosleep().

Which part of the ISO C standard defines either of these functions?


Not the ISO C standard. Maybe Posix?
Nov 14 '05 #5

Alex wrote:

Note that you seem to be asking for a way to achieve your solution ("How do
I use a sledgehammer to crack a walnut?"), not for a solution to your
problem ("How do I crack a walnut?"). This may well mean you don't get the
best end result.


He doesnt want to use a sledgehammer (sleep), he wants a finer and
tinyer one (nanosleep) ;)
just kidding,
robert
Nov 14 '05 #6
bh******@dodo.com.au (Macgyver) wrote:
Hi all,

does anyone know how to generate a millisecond delay in C, compiling
under Linux? I understand the function sleep() will generate a delay
down to a resolution of one second, but I need to be able to refine
this to milliseconds.

Any ideas?


Take the advice about asking in a different newsgroup, because
there is *far* more to this than meets the eye.

In fact, you shouldn't ask in comp.unix.programming because the
discussion you need is specific to Linux, not unix in general,
though they won't throw a hissy fit about it like you get here.

Try comp.os.linux.misc or better might be
comp.os.linux.development.apps.

--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) fl***@barrow.com
Nov 14 '05 #7
Robert Frunzke wrote:

Joona I Palaste wrote:
Which part of the ISO C standard defines either of these functions?


Not the ISO C standard. Maybe Posix?


1. POSIX isn't C. POSIX is an OS thing that has hooks originally
designed for C.

2. If it isn't ISO C, it's off-topic here. Try comp.programming.unix or
some such.
Nov 14 '05 #8
On Wed, 07 Jan 2004 12:08:57 +0100
Robert Frunzke <Ro**************@freenet.de> wrote:
Joona I Palaste wrote:
Robert Frunzke <Ro**************@freenet.de> scribbled the
following:
checkout the select() call - it is often used for such a purpose. or
nanosleep().

Which part of the ISO C standard defines either of these functions?


Not the ISO C standard. Maybe Posix?


That was Joonas point. This group is about ISO C, the Posix, Unix and
Linux experts hang out in other groups where answers involving these
functions will get properly reviewed for errors.
--
Flash Gordon
Paid to be a Geek & a Senior Software Developer
Although my email address says spam, it is real and I read it.
Nov 14 '05 #9

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

Similar topics

3
by: richard | last post by:
I am trying to do non-delay mode read from cin, i.e. char ch; ... while( cin.getch(ch) ) { ... } I want getch to return whenever there is a char typed (not wait till a newline is seen).
2
by: amos_s12 | last post by:
Hello everybody Is there a possibility to make a delay between two sql statements, namely one sql statement is performed, then there is a delay of some seconds and then rhe next statement is...
17
by: silveira neto | last post by:
Using a delay in C, using Linux. gcc-3.3 This program do a boy in a bike runing in the screen. :D Its cool to see about games and delay in C. #include<stdio.h> int branco(int j){ int k; for...
8
by: John | last post by:
Hi all: Is there a C function to make a procedure sleep or delay for a few seconds/minutes on Linux and Sun OS platform? Thanks
11
by: Yeounkun, Oh | last post by:
Hello. Sleep (x) function make a process sleep during x seconds. but, how to sleep during milliseconds... Pls. help me. Thank you. Regards.
14
by: Rene Grothmann | last post by:
I have managed to communicate between forms and Java applets. A button press sends the content of the text area to an applet, a second button gets some text from the applet and puts it into the...
16
by: sriever4u | last post by:
I am new to ARM linux, i am working on AT91RM9200 board and using ARM linuc C complier.. i want to know how to produce nanosecond delay using software...
1
by: maul581 | last post by:
I know the delay( ) function of Turbo C and used it in my project. By this function we can give intermediate delay in execution from 1 millisecond to 9999 millisecond. My main question is "Is it...
2
by: arun thakur | last post by:
hi all, how could i get a millisecond resolution timer in linux platform with GPS input of 1 PPS .i want to use this timer for the synchronized the channel switching mechanism in wireless medium....
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
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,...
1
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...
0
tracyyun
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
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.