/* kern_clock.c 4.3 %G% */
* Constant for decay filter for cpu usage.
double ccpu
= 0.95122942450071400909; /* exp(-1/20) */
* Clock is called straight from
* the real time clock interrupt.
* maintain user/system times
* lightning bolt wakeup (every second)
unsigned short kcount
[20000];
* We handle regular calls to the dh and dz silo input processors
* without using timeouts to save a little time.
int rintvl
= 0; /* every 1/60'th of sec check receivers */
register struct callo
*p1
, *p2
;
register struct proc
*pp
;
* else update first non-zero time
if(callout
[0].c_func
== NULL
)
while(p2
->c_time
<=0 && p2
->c_func
!=NULL
)
* if ps is high, just return
if(callout
[0].c_time
<= 0) {
while(p1
->c_func
!= 0 && p1
->c_time
<= 0) {
(*p1
->c_func
)(p1
->c_arg
);
while(p2
->c_func
= p1
->c_func
) {
* lightning bolt time-out
* In order to not take input character interrupts to use
* the input silo on DZ's we have to guarantee to echo
* characters regularly. This means that we have to
* call the timer routines predictably. Since blocking
* in these routines is at spl5(), we have to make spl5()
* really spl6() blocking off the clock to put this code
* here. Note also that it is critical that we run spl5()
* (i.e. really spl6()) in the receiver interrupt routines
* so we can't enter them recursively and transpose characters.
if (u
.u_procp
->p_textp
) {
register int xrss
= u
.u_procp
->p_textp
->x_rssize
;
if (s
> u
.u_vm
.vm_maxrss
)
if ((u
.u_vm
.vm_utime
+u
.u_vm
.vm_stime
+1)/HZ
> u
.u_limit
[LIM_CPU
]) {
psignal(u
.u_procp
, SIGXCPU
);
if (u
.u_limit
[LIM_CPU
] < INFINITY
- 5)
if(u
.u_procp
->p_nice
> NZERO
)
for (i
= 0; i
< DK_NDRIVE
; i
++)
if(pp
->p_cpu
% 16 == 0) {
pp
->p_pri
= pp
->p_usrpri
;
if (lbolt
% (HZ
/4) == 0) {
* machdep.c:unhang uses hangcnt to make sure uba
* doesn't forget to interrupt (this has been observed).
* This prevents an accumulation of < 5 second uba failures
* from summing to a uba reset.
for(pp
= &proc
[0]; pp
< &proc
[NPROC
]; pp
++)
if (pp
->p_stat
&& pp
->p_stat
!=SZOMB
) {
if (pp
->p_flag
& STIMO
) {
if(pp
->p_stat
==SSLEEP
||pp
->p_stat
==SSTOP
)
if (pp
->p_slptime
!= 127)
pp
->p_pctcpu
= ccpu
* pp
->p_pctcpu
+
(1.0 - ccpu
) * (pp
->p_cpticks
/(float)HZ
);
a
= (pp
->p_cpu
& 0377)*SCHMAG
+ pp
->p_nice
- NZERO
;
if ((pp
!= u
.u_procp
|| noproc
) &&
pp
->p_pri
!= pp
->p_usrpri
) {
pp
->p_pri
= pp
->p_usrpri
;
pp
->p_pri
= pp
->p_usrpri
;
* If there are pages that have been cleaned,
* jolt the pageout daemon to process them.
* We do this here so that these pages will be
* freed if there is an abundance of memory and the
* daemon would not be awakened otherwise.
wakeup((caddr_t
)&proc
[2]);
if (pp
->p_nice
== NZERO
&& u
.u_vm
.vm_utime
> 600 * HZ
)
pp
->p_pri
= pp
->p_usrpri
;
* We do this last since it
* may block on a page fault in user space.
addupc(pc
, &u
.u_prof
, 1);
register int indx
= ((int)pc
& 0x7fffffff) / 4;
if (indx
>= 0 && indx
< 20000)
* timeout is called to arrange that
* fun(arg) is called in tim/HZ seconds.
* An entry is sorted into the callout
* structure. The time in each structure
* entry is the number of HZ's more
* than the previous entry.
* In this way, decrementing the
* first entry has the effect of
* The panic is there because there is nothing
* intelligent to be done if an entry won't fit.
register struct callo
*p1
, *p2
;
while(p1
->c_func
!= 0 && p1
->c_time
<= t
) {
if (p1
>= &callout
[NCALL
-1])
panic("Timeout table overflow");
(p2
+1)->c_time
= p2
->c_time
;
(p2
+1)->c_func
= p2
->c_func
;
(p2
+1)->c_arg
= p2
->c_arg
;