[quagga-dev 3349] Re: thread_fetch ready logic

Paul Jakma paul at clubi.ie
Wed Apr 27 18:16:07 BST 2005

On Wed, 27 Apr 2005, Paul Jakma wrote:

> Any optimisations which 'short' a loop should make sure they dont 
> starve lower priority thread types.

Ah, ie:

- it's ok to /not/ check a thread type (eg background) if you know
   it couldn't have anything ready.

- it's not ok to short-circuit back to the top of the loop just
   because some thread type (eg IO) had work.

The latter is important: while testing the workqueue and zebra_rib 
queue stuff I had a version of the scheduler which short-circuited 
for IO and managed to almost completely starve out background threads 
because of it.

thread_process_fd then thread_process_timer (background) is fine, 
cause the IO will be first on the ready list, the background timer 
will yield pretty quickly anyway and even though its background, it 
is still important to do it.

So, in short - your patch is fine :). Though, its a bit ugly 
processing the timers beforehand.. Maybe a better way would be to 
move thread_timer_process to /after/ IO and short-circuit the select 
if timer_wait is 0?

Paul Jakma	paul at clubi.ie	paul at jakma.org	Key ID: 64A2FF6A
Remember, there's a big difference between kneeling down and bending over.
- Frank Zappa

More information about the Quagga-dev mailing list