Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!news.stack.nl!.POSTED!not-for-mail From: Willem Newsgroups: comp.lang.java.programmer,comp.lang.c Subject: Re: Arithmetic overflow checking Date: Thu, 8 Sep 2011 19:15:13 +0000 (UTC) Organization: Eindhoven University of Technology Lines: 27 Message-ID: References: <015aeb15-57db-48ab-9cd4-77f8448b632f@w24g2000yqw.googlegroups.com> <2rydnez7l-H5BYnTnZ2dnUVZ_vGdnZ2d@earthlink.com> <9LWdnZH2hdfmyYvTnZ2dnUVZ_vidnZ2d@posted.palinacquisition> <3797038f-22d1-40b2-8c12-60db5a0976b8@t5g2000yqj.googlegroups.com> <20110908210243.710b9d01@loki.yggdrasil.draxit.de> <20110908211243.7932aa0c@loki.yggdrasil.draxit.de> NNTP-Posting-Host: toad.stack.nl Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: mud.stack.nl 1315509313 15271 2001:610:1108:5010::135 (8 Sep 2011 19:15:13 GMT) X-Complaints-To: abuse@stack.nl NNTP-Posting-Date: Thu, 8 Sep 2011 19:15:13 +0000 (UTC) User-Agent: slrn/0.9.9p1 (FreeBSD) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7712 comp.lang.c:10031 Wolfgang Draxinger wrote: ) Am Thu, 8 Sep 2011 21:02:43 +0200 ) schrieb Wolfgang Draxinger : ) )> To give you some figures: Processing an interrupt takes Linux about 1 )> to 10??s. On a 3GHz CPU that amounts to 30000 clockcycles, and most )> modern, pipelined CPUs finish at least 1 instruction per clock cycle; )> on a Intel Pentium or Core for the majority of instructions have a up )> to 8 finished instructions per clock cycle. In the time your proposed )> overflow-check interrupt is processed you can do about 200000 flag )> checks. ) ) Well, I was off by a factor of ~10. The typical Linux ISR takes about ) 2000 clock cycles. Still going such a long way is still a lot slower ) than checking the flag in under a cycle. So if an overflow condition typically occurs less than 1 in 10000 times, the interrupt solution is better. SaSW, Willem -- Disclaimer: I am in no way responsible for any of the statements made in the above text. For all I know I might be drugged or something.. No I'm not paranoid. You all think I'm paranoid, don't you ! #EOT