470,858 Members | 1,639 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,858 developers. It's quick & easy.

c no busy waiting loop


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

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
signal(SIGHUP,sigHandler); //register signal
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,


Nov 21 '07 #1
1 5195
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

Post your reply

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

Similar topics

29 posts views Thread by Paul L. Du Bois | last post: by
4 posts views Thread by Smegly | last post: by
1 post views Thread by marc.gibian | last post: by
12 posts views Thread by Raymond Lewallen | last post: by
1 post views Thread by Michael S. Scherotter | last post: by
3 posts views Thread by vul | last post: by
1 post views Thread by placid | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.