lkml.org 
[lkml]   [2008]   [Nov]   [18]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
DateTue, 18 Nov 2008 21:26:52 +0000
FromAlan Cox <>
SubjectRe: Active waiting with yield()
> This makes a code branch that is very rarely tested and a potential bug. 
> Every such rarely executed branch is a danger and even a silly typo in the 
> code can hide there for many years without being noticed.

Learn to use a debugger. You want an unusual timing to occur you
breakpoint the relevant task and suspend it for a bit.

> So, I say msleep(1) instead of yield(). What are the counterarguments to 
> msleep?

msleep isn't particularly a problem. You are giving up the CPU and not
wasting so much power and you won't deadlock in realtime. Assuming you
only expect one or two msleep cycles its fine.

And if you think virtualisation and power management and correctness
(as Ingo noted) are a "bad reason" you need to wake up to the real world.

Alan


\
 
 \ /
  Last update: 2008-11-18 22:29    [from the cache]
©2003-2008