473,405 Members | 2,154 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,405 software developers and data experts.

c no busy waiting loop

1
Hello,

My question is as follows I have a condition x which I need to signal the current program to begin processing i/o. and when condition x is not met I need the program to sleep. I am pretty sure that the following is correct

while(1)
{
pause();
..
....
}
my question is how do I get it to recognize it's time to send a signal without having it continually poll to see if the condition is met.

//sigHandler defined elsewhere
ie:
signal(SIGHUP,sigHandler); //register signal
while(1)
{
pause(); //have process wait for sig
if( x==4) < -- is this still considered busy wait since it still needs to check to see
//if condition met
{
kill(getpid(),SIGHUP); //where SIGHUP can be any predefined signal in signal.h
}

}

any help would be greatfully appreciated,

Sincerely,

Jim
Nov 21 '07 #1
1 5691
weaknessforcats
9,208 Expert Mod 8TB
You have to continuously poll. Usually you poll and then sleep for a specified number of milliseconds.
Nov 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

29
by: Paul L. Du Bois | last post by:
Has anyone written a Queue.Queue replacement that avoids busy-waiting? It doesn't matter if it uses os-specific APIs (eg WaitForMultipleObjects). I did some googling around and haven't found...
4
by: Smegly | last post by:
Hi, I want to write a routine that periodically ( every t seconds) gets a value from a file and puts in into a queue. How can i implement this without getting into a busy-waiting loop . . ...
1
by: marc.gibian | last post by:
I am writing a simple C# application to read some files in an FTP drop directory. Occasionally the program will attempt to open a file that is in the process of being written. FileStream will throw...
5
by: Javaman59 | last post by:
I have a real-time simulation where the logic flows most easily with a busy while loop... while (continueFlagSet) { if (EventDue) ProcessNextEvent } Now, is there any thing to be concerned...
12
by: Raymond Lewallen | last post by:
How to wait for a process to stop completion is my goal. Obviously, the looping while waiting for the HasExited property is not a solution.. but thats the best I can come up off the top of my...
1
by: Michael S. Scherotter | last post by:
I have a proxy class derived from System.Web.Services.Protocols.SoapHTTPClient that calls a web service. Sometimes, because the call takes a longer time, I get the OLE server busy dialog. Is...
3
by: vul | last post by:
I need to copy the file (OutboxLog.txt produced by Fax service) right after it was updated. I'm using: System.IO.File.Copy(strSource, strDestination, True) to do that, but if the source file is...
1
by: placid | last post by:
Hi all, Just wondering if the cmd module in python uses "busy waiting" for "polling" user command input as this is inefficient. Cheers
13
by: mike3 | last post by:
Hi. Busy-waiting is a known anti-pattern that should be avoided. However, in C, there is no standard alternative, so when a wait is required and it's not busy, the program becomes 100%...
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
jinu1996
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...
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
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,...

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.