devcons: avoid division by zero reading Qsysstat
alexchandel got the kernel to crash with divide error on qemu 2.1.2/macosx at this location. probably caused by perfticks()/tsc being wrong or accounttime() not having been called yet from timer interrupt yet for some reason.
This commit is contained in:
parent
c8cf0cee47
commit
eb6a4fc1a4
1 changed files with 5 additions and 4 deletions
|
@ -581,13 +581,14 @@ consread(Chan *c, void *buf, long n, vlong off)
|
|||
bp += NUMSIZE;
|
||||
readnum(0, bp, NUMSIZE, mp->load, NUMSIZE);
|
||||
bp += NUMSIZE;
|
||||
l = mp->perf.period;
|
||||
if(l == 0)
|
||||
l = 1;
|
||||
readnum(0, bp, NUMSIZE,
|
||||
(mp->perf.avg_inidle*100)/mp->perf.period,
|
||||
NUMSIZE);
|
||||
(mp->perf.avg_inidle*100)/l, NUMSIZE);
|
||||
bp += NUMSIZE;
|
||||
readnum(0, bp, NUMSIZE,
|
||||
(mp->perf.avg_inintr*100)/mp->perf.period,
|
||||
NUMSIZE);
|
||||
(mp->perf.avg_inintr*100)/l, NUMSIZE);
|
||||
bp += NUMSIZE;
|
||||
*bp++ = '\n';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue