From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Denk Date: Sun, 23 Jan 2011 17:23:12 +0100 Subject: [U-Boot] [RFC] ARM timing code refactoring In-Reply-To: <4D3C0271.4070306@emk-elektronik.de> References: <4D3AAF63.1030600@free.fr> <20110122191928.49E141365DB@gemini.denx.de> <4D3B3B5C.2060205@free.fr> <20110122212601.9C8A2B187@gemini.denx.de> <4D3B5171.7090700@emk-elektronik.de> <20110123101217.E31DFB335@gemini.denx.de> <4D3C0271.4070306@emk-elektronik.de> Message-ID: <20110123162312.CDEDE1365DB@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Reinhard Meyer, In message <4D3C0271.4070306@emk-elektronik.de> you wrote: > > There were several suggestions about that in the past (including from me) > that involve rework everywhere HZ related timeouts are used. I still > prefer a method as follows (because it does not need repeated mul/div calculations > nor necessarily 64 bit arithmetic): > > u32 timeout = timeout_init(100); /* 100ms timeout */ > > do {...} while (!timed_out(timeout)); I dislike this approach. I immediately fear the same problem I just saw (incorrectly) in Albert's proposal - timeout_init() seems to store the timeouut information in some internal varoable, which is then checked by timed_out() - this is bound to fail as soon as somebody atttempts to nest timeouts. Your implementation may be different, but you can bet sooner or later comes up with such a bugy implementation. And it is not needed. PLease see my proposal: we do not needs several timer or timeout related functions, all we need is a plain "get timer" function, without any arguments. And the resulting code makes it obvious to the reader that such loops can be nested as you like. > time_out(x): > return ((i32)(x - fast_tick)) < 0; > > If the tick were really high speed (and then 64 bits), > fast_tick could be derived by shifting the tick some bits to the right. I have no idea what "fast_tick" versus "tick" means here, nor why we would need more than one tick. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de As a general rule, the freedom of any people can be judged by the volume of their laughter.