c - Controlled infinite loop uses too much resources -


i'm working in part of bigger project, has read lot of fifos , redirect them properly, depending on commands. achieve this, fifos read in order, in infinite loop.

the problem consumes resources. can understand process doing operations , waking processor, i'd avoid overload.

  • an option using signals, makes processing lot more chaotic, , it's difficult avoid cutting execution while processing 1 of commands.
  • another option using blocking read, need process each fifo, because don't know , when send command.
  • another option sleeping, don't think best option, , sleeping few milliseconds not lot of difference (i haven't tried yet).

do have other ideas avoid overloading?

would thread pool appropriate? http://en.wikipedia.org/wiki/thread_pool_pattern

you can have 1 process checks new work. when queue has something, thread can dispatched deal it. when finished, thread returns pool of available threads (thus name). model works dealing many small tasks not have shared state.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -