Thread (10 messages) flat view 10 messages, 5 authors, 2004-03-29

Re: [PATCH] Consolidate multiple implementations of jiffies-msecs conversions.

From: Edgar Toernig <hidden>
Date: 2004-03-26 20:46:34
Also in: lkml

Sridhar Samudrala wrote:
On Fri, 26 Mar 2004, Edgar Toernig wrote:
quoted
Sridhar Samudrala wrote:
quoted
[...]
-#define MSECS(ms)  (((ms)*HZ/1000)+1)
-return (((ms)*HZ+999)/1000);
+return (msecs / 1000) * HZ + (msecs % 1000) * HZ / 1000;
Did you check that all users of the new version will work correctly
with your rounding?  Explicit round-up of delays is often required,
especially when talking to hardware...
[...] 
I guess you are referring to cases when HZ < 1000(ex: 100) and msecs is
less than 10. In those cases, the new version returns 0, whereas some of the
older versions return 1.
Exactly - but not only <10.  Any value that is not exactly representable
in jiffies.  I.e. for a delay of 15ms one has to wait 2 jiffies on a 100HZ
system.  Your version would give 1 jiffy = 10ms -- too short.

Ciao, ET.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help