Re: signed int for interrupts??

Bill Foster (bill@kryten.kryten.com)
Sun, 8 Sep 1996 16:16:08 -0700 (PDT)


On Sun, 8 Sep 1996, Jon Lewis wrote:

> On Sun, 8 Sep 1996, Jon Lewis wrote:
>
> > 5: 1649726484 + cyclades
> > 9: 12023652 53c8xx
> > 10: 231379880 3c509
> > 11: -2104643917 + cyclades
>
> Now I'm really confused. I did some looking, and found that the interrupt
> counters _are_ or at least appear to be unsigned int.
>
> In kernel_stat.h:
> struct kernel_stat {
> ...
> unsigned int interrupts[NR_IRQS];
> ...
> };
>
> So why did my Irq 11 counter wrap at 2^31 rather than 2^32?

I believe it is because it is displayed as a signed number in
arch/i386/kernel/irq.c:

len += sprintf(buf+len, "%2d: %8d %c %s",
^^^

Here's a patch:
------------------------------------------------------------------------------
--- arch/i386/kernel/irq.c.orig Sun Sep 8 16:12:55 1996
+++ arch/i386/kernel/irq.c Sun Sep 8 16:13:49 1996
@@ -232,7 +232,7 @@
action = irq_action[i];
if (!action)
continue;
- len += sprintf(buf+len, "%2d: %8d %c %s",
+ len += sprintf(buf+len, "%2d: %8u %c %s",
i, kstat.interrupts[i],
(action->flags & SA_INTERRUPT) ? '+' : ' ',
action->name);
------------------------------------------------------------------------------

Bill Foster
bill@kryten.com