does looping wastes processing power

does looping wastes processing power

Post by tech.. » Sun, 26 Nov 2000 04:00:00

currently, i have a process that does nothing but wait for an event to
trigger off periodically.

i use SIGALRM to set the alarm.
the code is something like this

void alarm_handler(){


int main(){
   while (1) {



so my question is, does the infinite loop in the main method waste
processing power?
is there a better way to implement it?


Sent via
Before you buy.


1. main loop cpu waste

I am currently developing a daemon that is supposed to check whether there
are any connection attempts by calling select() on a listening tcp/ip
socket. select() is set to immediately timeout, because in the main while()
loop, a function is called that does some unix ipc with other client
processes. you could think of it as an IRC chat server that has to
distribute messages across all of it's clients.

sample pseudo code

        select(socket); //timeout==0
        ipc_function(); //needs to be called periodically


my problem is that the while() loop eats up almost all of my server's cpu
time. is there any practical solution to this problem?

any help would be appreciated!



2. A different partition question

3. How much CPU power does the Mac OS waste?

4. filesystem replication and rdist

5. getting process i/o wasted time ...

6. Linux 2.0.27 and Sniffit

7. How to not have process number / 'done' line for background process?

8. Disk Drive on classis doesn't eject

9. For in do done, loop.

10. Doing something in the idle loop

11. For in do done, loop.

12. Oops on 2.5.1-pre6 doing mkreiserfs on loop device

13. How to read lines from a file without doing a loop ?