/* kern_clock.c 3.6 %H% */
* 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
= 4; /* every 1/15'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_procp
->p_nice
> NZERO
)
if(pp
->p_cpu
% 16 == 0) {
pp
->p_pri
= pp
->p_usrpri
;
if (lbolt
% (HZ
/4) == 0) {
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
)
if(pp
->p_stat
==SSLEEP
||pp
->p_stat
==SSTOP
)
if (pp
->p_slptime
!= 127)
ave(pp
->p_aveflt
, pp
->p_faults
, 5);
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
;