473,785 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pausing/Waiting in C

Hi everyone,
I'm developing an application in C; basically a linked list, with a series
of "events" to be popped off, separated by a command to pause reading off
the next event in the list. It has been sometime since I last did C, and
that was the first K&R version! Is there a command to pause an app for
a period of time, as all the commands I am familiar with specify pauses
for integer numbers of seconds, and what I would like is fractions of a
second, preferably milliseconds if possible

TIA

Paul

--
----
Home: http://www.paullee.com
Woes: http://www.dr_paul_lee.btinternet.co.uk/zzq.shtml
Jan 10 '07
25 2317
"Barry" <ba****@nullhig hstream.netwrot e in message
news:12******** *****@corp.supe rnews.com...
>
Of course we have gotten so far off topic for clc it doesn't matter.
But, every embedded system I have worked on (and you have used all
of them, directly or indirectly :-)) also respond to hardware interrupts.
That has been my experience, too. I work in the auto industry, and typical
interrupts are timekeeping (i.e. periodic interrupt) and vehicle network
receive.

I think in the abstract it would be possible to find a small embedded system
without interrupts ... just that I've never encountered one.

I thought about this briefly as I was typing my post, but decided it would
just add unnecessary complexity. The important point for the individual I
was responding to is that in most applications (except small embedded
systems), spin-locking the CPU to get a time delay is usually a bad thing to
do.
Jan 11 '07 #21
On Wed, 10 Jan 2007 21:20:40 -0600, David T. Ashley wrote
(in article <Uu************ *************** ***@giganews.co m>):
"Kwebway Konongo" <pa**@pNaOuSlPl AeMe.comwrote in message
news:97******** *************@b t.com...
>Hi everyone,
I'm developing an application in C; basically a linked list, with a series
of "events" to be popped off, separated by a command to pause reading off
the next event in the list. It has been sometime since I last did C, and
that was the first K&R version! Is there a command to pause an app for
a period of time, as all the commands I am familiar with specify pauses
for integer numbers of seconds, and what I would like is fractions of a
second, preferably milliseconds if possible

OS-dependent question.

Any form of spin-wait is bad programming practice (but I suppose it would
work).

In Linux it is usleep():
Maybe, maybe not. In some cases, nanosleep() is better. Yet another
example of why it's better to just redirect them to an appropriate
group.
In Windows, I'm not sure, but there are various references on the Microsoft
website to sleep(). Since Microsoft tries to support straightforward Unix
applications, there is a good chance you'll find sleep() or usleep() as a
Windows API system call.
And you also find Sleep() [note the upper case S]

Ditto above...
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw

Jan 11 '07 #22
"David T. Ashley" <dt*@e3ft.comwr ites:
[...]
If you have any further questions or observations, please write me directly
at dt*@e3ft.com and answer my SPAM filtering system's automatic reply. I
might know one or two things about small embedded systems.
Or take it to comp.arch.embed ded.

--
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 11 '07 #23
On Wed, 10 Jan 2007 19:58:25 -0600, in comp.lang.c , "Barry"
<ba****@nullhig hstream.netwrot e:
>
"user923005 " <dc*****@connx. comwrote in message
news:11******* *************** @i56g2000hsf.go oglegroups.com. ..
>Kwebway Konongo wrote:
that was the first K&R version! Is there a command to pause an app for
a period of time,
>From the C-FAQ:
19.37: How can I implement a delay, or time a user's response, with
sub- second resolution?

A: Unfortunately, there is no portable way.
(snip rest of quote from FAQ)
>Most of your response has nothing to do with C.
You do know it was a quote from this groups FAQ don't you?
>Instead you posed a response irrelevant to C, and lacking of
many proper solutions.
If you think the FAQ wrong, suggest some corrections to Steve Summit,
who owns it.

"The lusers I know are so clueless, that if they were dipped in clue
musk and dropped in the middle of pack of horny clues, on clue prom
night during clue happy hour, they still couldn't get a clue."

--
Mark McIntyre
Jan 11 '07 #24
Barry wrote:
"user923005 " <dc*****@connx. comwrote in message news:11******** **************@ i56g2000hsf.goo glegroups.com.. .
>From the C-FAQ:
19.37: How can I implement a delay, or time a user's response, with
....
[snip]
....
References: H&S Sec. 18.1 pp. 398-9; PCS Sec. 12 pp. 197-8,215-
6; POSIX Sec. 4.5.2.

Most of your response has nothing to do with C. You should have
just referred the OP to an appropriate news group.

Instead you posed a response irrelevant to C, and lacking of
many proper solutions.
The post came straight from *this group's FAQ*. I can't imagine a more
on-topic or relevant-to-C source of information for this group.
--
Clark S. Cox III
cl*******@gmail .com
Jan 11 '07 #25
Barry wrote:
"user923005 " <dc*****@connx. comwrote in message
[snip]
Most of your response has nothing to do with C. You should have
just referred the OP to an appropriate news group.

Instead you posed a response irrelevant to C, and lacking of
many proper solutions.
I assume that your response is a joke.
Otherwise, I guess that you are a troll.
Do you know what the C-FAQ is? If so, next time add a smiley for me:
;-)
I'm smiley imparied sometimes.

Jan 12 '07 #26

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

Similar topics

12
4171
by: Simon John | last post by:
I'm writing a PyQt network client for XMMS, using the InetCtrl plugin, that on connection receives a track length. To save on bandwidth, I don't want to be continually querying the server for updates (e.g. has the current track finished yet?) so I figured the best thing to do is just update after the track length has expired. So, how would I make a Python program automatically call a function after a preset period of time, without the...
7
7617
by: Dr. Know | last post by:
I am working on an ASP page that writes to several databases, ranging from MDBs to x-base. One of the tasks involves using an existing highest value from the DB and incrementing it before inserting a new record. I am using Application.Lock and .Unlock together with an application variable to negotiate access to the DB routine to one session (user) at a time. This is to ensure that the ID numbers are cleanly incremented, and that no...
2
1803
by: Dave Harris | last post by:
I am having a bit of trouble with form manipulation. I am working on a program where the user opens one form and when all the processes are done, he/she clicks on "Continue" which opens the next form in the program's sequence where more data processing takes place. Here is a snippet of code from the form I am currently working on. I need the application to pause after the "objReader.Close()" statement until the user clicks a button on the...
7
2695
by: Charles Law | last post by:
My first thought was to call WorkerThread.Suspend but the help cautions against this (for good reason) because the caller has no control over where the thread actually stops, and it might have a lock pending, for example. I want to be able to stop a thread temporarily, and then optionally resume it or stop it for good.
2
5254
by: BLUE | last post by:
I would like to pause an application while the GUI display a Label saying "Logging in...". System.Timers System.Windows.Forms.Timer System.Threading.Timer System.Threading ==Thread.Sleep Which one? In the last case Sleep must be applied to what(Application, this or what)?
0
2177
by: Grayzag | last post by:
Hi there, As part of my Software course, i have to create a game. Since I originally started out with python, I was used to it being really easy to create a main loop to control the game with a simple while statement, pausing where input is needed from the user. Now that I have moved on to VB, I can seem to find a way to pause the while statements until the user does something (e.g. clicks a button). When i start my app, if just throws...
12
3330
by: greg | last post by:
Hi, Can anyone help me with the following issue: How can I pause the execution of a program until a given file is created (by another process) in a specified directory? Any ideas would be highly appreciated. Thanks!
3
3903
by: Lucress Carol | last post by:
Hi everyone, I'm having troubles with pausing and continuing MFC Thread.For test purposes I've created in my MFC Dialog application a progress Bar Control, a Start Button and a Stop Button.The idea is to start the progress Bar Control by clicking on the Start Button and I would like to pause (Stop Button) the process at anytime and continue it when I click on the Start Button.I had a look at the following homepage:...
0
1314
by: thesti | last post by:
hello, i have some jbuttons in my frame. and i have a recursive method, which will check a certain condition and if satisfied, will move one of the jbuttons location to somewhere else in the frame and then remove the jbutton from the frame, then the process is repeated. (since i use null layout for my frame, i can call the setBounds method) the problem is, the method will keep running without pausing, so i couldn't see which...
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9481
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10336
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, 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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9953
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 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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8978
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7502
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
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 we have to send another system
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.