-/* $OpenBSD: kern_clock.c,v 1.105 2022/08/14 01:58:27 jsg Exp $ */
+/* $OpenBSD: kern_clock.c,v 1.106 2023/02/04 19:33:03 cheloha Exp $ */
/* $NetBSD: kern_clock.c,v 1.34 1996/06/09 04:51:03 briggs Exp $ */
/*-
void
initclocks(void)
{
- int i;
-
ticks = INT_MAX - (15 * 60 * hz);
jiffies = ULONG_MAX - (10 * 60 * hz);
cpu_initclocks();
/*
- * Compute profhz/stathz, and fix profhz if needed.
+ * Compute profhz/stathz.
*/
- i = stathz ? stathz : hz;
- if (profhz == 0)
- profhz = i;
- psratio = profhz / i;
+ psratio = profhz / stathz;
inittimecounter();
}
}
}
- /*
- * If no separate statistics clock is available, run it from here.
- */
- if (stathz == 0)
- statclock(frame);
-
if (--ci->ci_schedstate.spc_rrticks <= 0)
roundrobin(ci);
if ((pr->ps_flags & PS_PROFIL) == 0) {
atomic_setbits_int(&pr->ps_flags, PS_PROFIL);
- if (++profprocs == 1 && stathz != 0) {
+ if (++profprocs == 1) {
s = splstatclock();
psdiv = pscnt = psratio;
setstatclockrate(profhz);
if (pr->ps_flags & PS_PROFIL) {
atomic_clearbits_int(&pr->ps_flags, PS_PROFIL);
- if (--profprocs == 0 && stathz != 0) {
+ if (--profprocs == 0) {
s = splstatclock();
psdiv = pscnt = 1;
setstatclockrate(stathz);
clkinfo.tick = tick;
clkinfo.hz = hz;
clkinfo.profhz = profhz;
- clkinfo.stathz = stathz ? stathz : hz;
+ clkinfo.stathz = stathz;
return (sysctl_rdstruct(where, sizep, newp, &clkinfo, sizeof(clkinfo)));
}
-/* $OpenBSD: kern_resource.c,v 1.76 2022/11/17 18:53:13 deraadt Exp $ */
+/* $OpenBSD: kern_resource.c,v 1.77 2023/02/04 19:33:03 cheloha Exp $ */
/* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */
/*-
struct timespec *ip)
{
u_quad_t st, ut, it;
- int freq;
st = tup->tu_sticks;
ut = tup->tu_uticks;
return;
}
- freq = stathz ? stathz : hz;
-
- st = st * 1000000000 / freq;
+ st = st * 1000000000 / stathz;
sp->tv_sec = st / 1000000000;
sp->tv_nsec = st % 1000000000;
- ut = ut * 1000000000 / freq;
+ ut = ut * 1000000000 / stathz;
up->tv_sec = ut / 1000000000;
up->tv_nsec = ut % 1000000000;
if (ip != NULL) {
- it = it * 1000000000 / freq;
+ it = it * 1000000000 / stathz;
ip->tv_sec = it / 1000000000;
ip->tv_nsec = it % 1000000000;
}
-/* $OpenBSD: kern_time.c,v 1.161 2023/01/02 23:09:48 guenther Exp $ */
+/* $OpenBSD: kern_time.c,v 1.162 2023/02/04 19:33:03 cheloha Exp $ */
/* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */
/*
struct timespec ts;
struct proc *q;
u_int64_t scale;
- int error = 0, realstathz;
+ int error = 0;
memset(&ts, 0, sizeof(ts));
- realstathz = (stathz == 0) ? hz : stathz;
clock_id = SCARG(uap, clock_id);
switch (clock_id) {
break;
case CLOCK_PROCESS_CPUTIME_ID:
case CLOCK_THREAD_CPUTIME_ID:
- ts.tv_nsec = 1000000000 / realstathz;
+ ts.tv_nsec = 1000000000 / stathz;
break;
default:
/* check for clock from pthread_getcpuclockid() */
if (q == NULL)
error = ESRCH;
else
- ts.tv_nsec = 1000000000 / realstathz;
+ ts.tv_nsec = 1000000000 / stathz;
KERNEL_UNLOCK();
} else
error = EINVAL;
-/* $OpenBSD: sched_bsd.c,v 1.73 2022/12/05 23:18:37 deraadt Exp $ */
+/* $OpenBSD: sched_bsd.c,v 1.74 2023/02/04 19:33:03 cheloha Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*-
struct proc *p;
int s;
unsigned int newcpu;
- int phz;
-
- /*
- * If we have a statistics clock, use that to calculate CPU
- * time, otherwise revert to using the profiling clock (which,
- * in turn, defaults to hz if there is no separate profiling
- * clock available)
- */
- phz = stathz ? stathz : profhz;
- KASSERT(phz);
LIST_FOREACH(p, &allproc, p_list) {
/*
* p_pctcpu is only for diagnostic tools such as ps.
*/
#if (FSHIFT >= CCPU_SHIFT)
- p->p_pctcpu += (phz == 100)?
+ p->p_pctcpu += (stathz == 100)?
((fixpt_t) p->p_cpticks) << (FSHIFT - CCPU_SHIFT):
100 * (((fixpt_t) p->p_cpticks)
- << (FSHIFT - CCPU_SHIFT)) / phz;
+ << (FSHIFT - CCPU_SHIFT)) / stathz;
#else
p->p_pctcpu += ((FSCALE - ccpu) *
- (p->p_cpticks * FSCALE / phz)) >> FSHIFT;
+ (p->p_cpticks * FSCALE / stathz)) >> FSHIFT;
#endif
p->p_cpticks = 0;
newcpu = (u_int) decay_cpu(loadfac, p->p_estcpu);