diff options
author | phk <phk@FreeBSD.org> | 1998-03-30 09:56:58 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1998-03-30 09:56:58 +0000 |
commit | 9b703b14551addf9806978973e2ddc427d4908b4 (patch) | |
tree | 91f2de8432f719153d0de9465a9ebeee33c29077 /sys/i386 | |
parent | add2782c4ec0d7c4447da2b33d1413a2754f8a3e (diff) | |
download | FreeBSD-src-9b703b14551addf9806978973e2ddc427d4908b4.zip FreeBSD-src-9b703b14551addf9806978973e2ddc427d4908b4.tar.gz |
Eradicate the variable "time" from the kernel, using various measures.
"time" wasn't a atomic variable, so splfoo() protection were needed
around any access to it, unless you just wanted the seconds part.
Most uses of time.tv_sec now uses the new variable time_second instead.
gettime() changed to getmicrotime(0.
Remove a couple of unneeded splfoo() protections, the new getmicrotime()
is atomic, (until Bruce sets a breakpoint in it).
A couple of places needed random data, so use read_random() instead
of mucking about with time which isn't random.
Add a new nfs_curusec() function.
Mark a couple of bogosities involving the now disappeard time variable.
Update ffs_update() to avoid the weird "== &time" checks, by fixing the
one remaining call that passwd &time as args.
Change profiling in ncr.c to use ticks instead of time. Resolution is
the same.
Add new function "tvtohz()" to avoid the bogus "splfoo(), add time, call
hzto() which subtracts time" sequences.
Reviewed by: bde
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/apm/apm.c | 9 | ||||
-rw-r--r-- | sys/i386/bios/apm.c | 9 | ||||
-rw-r--r-- | sys/i386/i386/symbols.raw | 4 | ||||
-rw-r--r-- | sys/i386/i386/trap.c | 6 | ||||
-rw-r--r-- | sys/i386/i386/tsc.c | 13 | ||||
-rw-r--r-- | sys/i386/isa/clock.c | 13 | ||||
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_sup.c | 6 | ||||
-rw-r--r-- | sys/i386/linux/linux_misc.c | 10 |
8 files changed, 47 insertions, 23 deletions
diff --git a/sys/i386/apm/apm.c b/sys/i386/apm/apm.c index 58e75b8..204a72f 100644 --- a/sys/i386/apm/apm.c +++ b/sys/i386/apm/apm.c @@ -15,7 +15,7 @@ * * Sep, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) * - * $Id: apm.c,v 1.68 1998/01/24 02:54:08 eivind Exp $ + * $Id: apm.c,v 1.69 1998/02/09 06:08:06 eivind Exp $ */ #include "opt_devfs.h" @@ -364,9 +364,14 @@ apm_default_resume(void *arg) pl = splsoftclock(); inittodr(0); /* adjust time to RTC */ microtime(&resume_time); - tmp_time = time; /* because 'time' is volatile */ + getmicrotime(&tmp_time); timevaladd(&tmp_time, &diff_time); + +#ifdef FIXME + /* XXX THIS DOESN'T WORK!!! */ time = tmp_time; +#endif + #ifdef APM_FIXUP_CALLTODO /* Calculate the delta time suspended */ timevalsub(&resume_time, &suspend_time); diff --git a/sys/i386/bios/apm.c b/sys/i386/bios/apm.c index 58e75b8..204a72f 100644 --- a/sys/i386/bios/apm.c +++ b/sys/i386/bios/apm.c @@ -15,7 +15,7 @@ * * Sep, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) * - * $Id: apm.c,v 1.68 1998/01/24 02:54:08 eivind Exp $ + * $Id: apm.c,v 1.69 1998/02/09 06:08:06 eivind Exp $ */ #include "opt_devfs.h" @@ -364,9 +364,14 @@ apm_default_resume(void *arg) pl = splsoftclock(); inittodr(0); /* adjust time to RTC */ microtime(&resume_time); - tmp_time = time; /* because 'time' is volatile */ + getmicrotime(&tmp_time); timevaladd(&tmp_time, &diff_time); + +#ifdef FIXME + /* XXX THIS DOESN'T WORK!!! */ time = tmp_time; +#endif + #ifdef APM_FIXUP_CALLTODO /* Calculate the delta time suspended */ timevalsub(&resume_time, &suspend_time); diff --git a/sys/i386/i386/symbols.raw b/sys/i386/i386/symbols.raw index e530aacc..bdc3b3c 100644 --- a/sys/i386/i386/symbols.raw +++ b/sys/i386/i386/symbols.raw @@ -1,6 +1,6 @@ # @(#)symbols.raw 7.6 (Berkeley) 5/8/91 # -# $Id: symbols.raw,v 1.10 1997/04/16 15:09:37 ache Exp $ +# $Id: symbols.raw,v 1.11 1997/04/26 11:45:26 peter Exp $ # @@ -72,8 +72,8 @@ #savecore _dumpdev _dumplo + _time_second _version - _time _dumpsize _panicstr _dumpmag diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index f4475bb..e840062 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 - * $Id: trap.c,v 1.123 1998/03/23 19:52:37 jlemon Exp $ + * $Id: trap.c,v 1.124 1998/03/28 10:32:57 bde Exp $ */ /* @@ -519,11 +519,11 @@ kernel_trap: { static unsigned lastalert = 0; - if(time.tv_sec - lastalert > 10) + if(time_second - lastalert > 10) { log(LOG_WARNING, "NMI: power fail\n"); sysbeep(TIMER_FREQ/880, hz); - lastalert = time.tv_sec; + lastalert = time_second; } return; } diff --git a/sys/i386/i386/tsc.c b/sys/i386/i386/tsc.c index 6588165..1df24b7 100644 --- a/sys/i386/i386/tsc.c +++ b/sys/i386/i386/tsc.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.116 1998/03/14 03:11:50 tegge Exp $ + * $Id: clock.c,v 1.117 1998/03/16 10:06:58 phk Exp $ */ /* @@ -237,12 +237,19 @@ clkintr(struct clockframe frame) if ((timer0_prescaler_count += timer0_max_count) >= hardclock_max_count) { timer0_prescaler_count -= hardclock_max_count; +#ifdef FIXME + /* + * XXX: This magic doesn't work, but It shouldn't be + * needed now anyway since we will not be able to + * aquire the i8254 if it is used for timecounting. + */ /* * See microtime.s for this magic. */ time.tv_usec += (27465 * timer0_prescaler_count) >> 15; if (time.tv_usec >= 1000000) time.tv_usec -= 1000000; +#endif hardclock(&frame); setdelayed(); timer0_max_count = hardclock_max_count; @@ -844,7 +851,7 @@ inittodr(time_t base) sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0); - y = time.tv_sec - sec; + y = time_second - sec; if (y <= -2 || y >= 2) { /* badly off, adjust it */ s = splclock(); @@ -873,7 +880,7 @@ resettodr() return; s = splclock(); - tm = time.tv_sec; + tm = time_second; splx(s); /* Disable RTC updates and interrupts. */ diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c index 6588165..1df24b7 100644 --- a/sys/i386/isa/clock.c +++ b/sys/i386/isa/clock.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.116 1998/03/14 03:11:50 tegge Exp $ + * $Id: clock.c,v 1.117 1998/03/16 10:06:58 phk Exp $ */ /* @@ -237,12 +237,19 @@ clkintr(struct clockframe frame) if ((timer0_prescaler_count += timer0_max_count) >= hardclock_max_count) { timer0_prescaler_count -= hardclock_max_count; +#ifdef FIXME + /* + * XXX: This magic doesn't work, but It shouldn't be + * needed now anyway since we will not be able to + * aquire the i8254 if it is used for timecounting. + */ /* * See microtime.s for this magic. */ time.tv_usec += (27465 * timer0_prescaler_count) >> 15; if (time.tv_usec >= 1000000) time.tv_usec -= 1000000; +#endif hardclock(&frame); setdelayed(); timer0_max_count = hardclock_max_count; @@ -844,7 +851,7 @@ inittodr(time_t base) sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0); - y = time.tv_sec - sec; + y = time_second - sec; if (y <= -2 || y >= 2) { /* badly off, adjust it */ s = splclock(); @@ -873,7 +880,7 @@ resettodr() return; s = splclock(); - tm = time.tv_sec; + tm = time_second; splx(s); /* Disable RTC updates and interrupts. */ diff --git a/sys/i386/isa/pcvt/pcvt_sup.c b/sys/i386/isa/pcvt/pcvt_sup.c index 24144e1..3b00191 100644 --- a/sys/i386/isa/pcvt/pcvt_sup.c +++ b/sys/i386/isa/pcvt/pcvt_sup.c @@ -1923,7 +1923,7 @@ getrand(void) #endif static unsigned long seed = 1; register u_short res = (u_short)seed; - seed = seed * 1103515245L + time.tv_sec; + seed = seed * 1103515245L + time_second; return res; } @@ -2082,9 +2082,9 @@ pcvt_scrnsv_reset(void) int reschedule = 0; if((scrnsv_active == 1 || scrnsv_timeout) && - last_schedule != time.tv_sec) + last_schedule != time_second) { - last_schedule = time.tv_sec; + last_schedule = time_second; reschedule = 1; untimeout(scrnsv_timedout, NULL, scrnsv_timeout_ch); } diff --git a/sys/i386/linux/linux_misc.c b/sys/i386/linux/linux_misc.c index d267130..2ee3cb2 100644 --- a/sys/i386/linux/linux_misc.c +++ b/sys/i386/linux/linux_misc.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_misc.c,v 1.33 1997/11/06 19:28:58 phk Exp $ + * $Id: linux_misc.c,v 1.34 1998/02/25 05:33:06 bde Exp $ */ #include <sys/param.h> @@ -73,9 +73,9 @@ linux_alarm(struct proc *p, struct linux_alarm_args *args) it.it_value.tv_usec = 0; it.it_interval.tv_sec = 0; it.it_interval.tv_usec = 0; - s = splclock(); + s = splclock(); /* XXX Still needed ? */ old_it = p->p_realtimer; - tv = time; + getmicrotime(&tv); if (timerisset(&old_it.it_value)) if (timercmp(&old_it.it_value, &tv, <)) timerclear(&old_it.it_value); @@ -84,10 +84,10 @@ linux_alarm(struct proc *p, struct linux_alarm_args *args) splx(s); if (itimerfix(&it.it_value) || itimerfix(&it.it_interval)) return EINVAL; - s = splclock(); + s = splclock(); /* XXX Still needed ? */ if (timerisset(&p->p_realtimer.it_value)) untimeout(realitexpire, (caddr_t)p, p->p_ithandle); - tv = time; + getmicrotime(&tv); if (timerisset(&it.it_value)) { timevaladd(&it.it_value, &tv); p->p_ithandle = timeout(realitexpire, (caddr_t)p, hzto(&it.it_value)); |