SCCS-vsn: sys/kern/kern_time.c 7.17
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)kern_time.c 7.16 (Berkeley) %G%
+ * @(#)kern_time.c 7.17 (Berkeley) %G%
*/
#include "param.h"
#include "resourcevar.h"
#include "kernel.h"
*/
#include "param.h"
#include "resourcevar.h"
#include "kernel.h"
#include "proc.h"
#include "vnode.h"
#include "proc.h"
#include "vnode.h"
+ struct timeval atv, delta;
struct timezone atz;
int error, s;
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
struct timezone atz;
int error, s;
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
+ /* Verify all parameters before changing time. */
+ if (uap->tv &&
+ (error = copyin((caddr_t)uap->tv, (caddr_t)&atv, sizeof(atv))))
+ return (error);
+ if (uap->tzp &&
+ (error = copyin((caddr_t)uap->tzp, (caddr_t)&atz, sizeof(atz))))
+ return (error);
- if (error = copyin((caddr_t)uap->tv, (caddr_t)&atv,
- sizeof (struct timeval)))
- return (error);
/* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */
/* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */
- boottime.tv_sec += atv.tv_sec - time.tv_sec;
- LEASE_UPDATETIME(atv.tv_sec - time.tv_sec);
- s = splhigh(); time = atv; splx(s);
+ s = splclock();
+ /* nb. delta.tv_usec may be < 0, but this is OK here */
+ delta.tv_sec = atv.tv_sec - time.tv_sec;
+ delta.tv_usec = atv.tv_usec - time.tv_usec;
+ time = atv;
+ (void) splsoftclock();
+ timevaladd(&boottime, &delta);
+ timevalfix(&boottime);
+ timevaladd(&runtime, &delta);
+ timevalfix(&runtime);
+ LEASE_UPDATETIME(delta.tv_sec);
+ splx(s);
- if (uap->tzp && (error = copyin((caddr_t)uap->tzp, (caddr_t)&atz,
- sizeof (atz))) == 0)
}
extern int tickadj; /* "standard" clock skew, us./tick */
}
extern int tickadj; /* "standard" clock skew, us./tick */
if (timercmp(&aitv.it_value, &time, <))
timerclear(&aitv.it_value);
else
if (timercmp(&aitv.it_value, &time, <))
timerclear(&aitv.it_value);
else
- timevalsub(&aitv.it_value, &time);
+ timevalsub(&aitv.it_value,
+ (struct timeval *)&time);
} else
aitv = p->p_stats->p_timer[uap->which];
splx(s);
} else
aitv = p->p_stats->p_timer[uap->which];
splx(s);
if (uap->which == ITIMER_REAL) {
untimeout(realitexpire, (caddr_t)p);
if (timerisset(&aitv.it_value)) {
if (uap->which == ITIMER_REAL) {
untimeout(realitexpire, (caddr_t)p);
if (timerisset(&aitv.it_value)) {
- timevaladd(&aitv.it_value, &time);
+ timevaladd(&aitv.it_value, (struct timeval *)&time);
timeout(realitexpire, (caddr_t)p, hzto(&aitv.it_value));
}
p->p_realtimer = aitv;
timeout(realitexpire, (caddr_t)p, hzto(&aitv.it_value));
}
p->p_realtimer = aitv;
* This is where delay in processing this timeout causes multiple
* SIGALRM calls to be compressed into one.
*/
* This is where delay in processing this timeout causes multiple
* SIGALRM calls to be compressed into one.
*/
-realitexpire(p)
- register struct proc *p;
+void
+realitexpire(arg)
+ void *arg;
+ register struct proc *p;
+ p = (struct proc *)arg;
psignal(p, SIGALRM);
if (!timerisset(&p->p_realtimer.it_interval)) {
timerclear(&p->p_realtimer.it_value);
psignal(p, SIGALRM);
if (!timerisset(&p->p_realtimer.it_interval)) {
timerclear(&p->p_realtimer.it_value);
* of microseconds, which must be less than a second,
* i.e. < 1000000. If the timer expires, then reload
* it. In this case, carry over (usec - old value) to
* of microseconds, which must be less than a second,
* i.e. < 1000000. If the timer expires, then reload
* it. In this case, carry over (usec - old value) to
- * reducint the value reloaded into the timer so that
+ * reduce the value reloaded into the timer so that
* the timer does not drift. This routine assumes
* that it is called in a context where the timers
* on which it is operating cannot change in value.
* the timer does not drift. This routine assumes
* that it is called in a context where the timers
* on which it is operating cannot change in value.