32 #include <sys/cdefs.h>
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/limits.h>
38 #include <sys/clock.h>
40 #include <sys/mutex.h>
41 #include <sys/sysproto.h>
42 #include <sys/eventhandler.h>
43 #include <sys/resourcevar.h>
44 #include <sys/signalvar.h>
45 #include <sys/kernel.h>
46 #include <sys/syscallsubr.h>
47 #include <sys/sysctl.h>
48 #include <sys/sysent.h>
51 #include <sys/posix4.h>
53 #include <sys/timers.h>
54 #include <sys/timetc.h>
55 #include <sys/vnode.h>
58 #include <vm/vm_extern.h>
60 #define MAX_CLOCKS (CLOCK_MONOTONIC+1)
61 #define CPUCLOCK_BIT 0x80000000
62 #define CPUCLOCK_PROCESS_BIT 0x40000000
63 #define CPUCLOCK_ID_MASK (~(CPUCLOCK_BIT|CPUCLOCK_PROCESS_BIT))
64 #define MAKE_THREAD_CPUCLOCK(tid) (CPUCLOCK_BIT|(tid))
65 #define MAKE_PROCESS_CPUCLOCK(pid) \
66 (CPUCLOCK_BIT|CPUCLOCK_PROCESS_BIT|(pid))
81 static int settime(
struct thread *,
struct timeval *);
89 static struct itimer *
itimer_find(
struct proc *,
int);
96 struct itimerspec *,
struct itimerspec *);
105 #define CLOCK_CALL(clock, call, arglist) \
106 ((*posix_clocks[clock].call) arglist)
112 settime(
struct thread *td,
struct timeval *tv)
114 struct timeval delta, tv1, tv2;
115 static struct timeval maxtime, laststep;
136 if (delta.tv_sec < 0 || delta.tv_usec < 0) {
140 if (tv1.tv_sec > maxtime.tv_sec)
144 if (tv2.tv_sec < -1) {
145 tv->tv_sec = maxtime.tv_sec - 1;
146 printf(
"Time adjustment clamped to -1 second\n");
149 if (tv1.tv_sec == laststep.tv_sec) {
153 if (delta.tv_sec > 1) {
154 tv->tv_sec = tv1.tv_sec + 1;
155 printf(
"Time adjustment clamped to +1 second\n");
161 ts.tv_sec = tv->tv_sec;
162 ts.tv_nsec = tv->tv_usec * 1000;
170 #ifndef _SYS_SYSPROTO_H_
186 error = copyout(&clk_id, uap->
clock_id,
sizeof(clockid_t));
200 case CPUCLOCK_WHICH_PID:
202 error =
pget(
id, PGET_CANSEE | PGET_NOTID, &p);
208 pid = td->td_proc->p_pid;
212 case CPUCLOCK_WHICH_TID:
213 tid =
id == 0 ? td->td_tid : id;
221 #ifndef _SYS_SYSPROTO_H_
236 error = copyout(&ats, uap->
tp,
sizeof(ats));
245 ats->tv_sec = runtime / 1000000;
246 ats->tv_nsec = runtime % 1000000 * 1000;
252 uint64_t runtime, curtime, switchtime;
254 if (targettd == NULL) {
256 switchtime = PCPU_GET(switchtime);
258 runtime = curthread->td_runtime;
260 runtime += curtime - switchtime;
262 thread_lock(targettd);
263 runtime = targettd->td_runtime;
264 thread_unlock(targettd);
277 runtime = targetp->p_rux.rux_runtime;
278 PROC_SUNLOCK(targetp);
283 get_cputime(
struct thread *td, clockid_t clock_id,
struct timespec *ats)
294 td2 =
tdfind(tid, p->p_pid);
298 PROC_UNLOCK(td2->td_proc);
301 error =
pget(pid, PGET_CANSEE, &p2);
313 struct timeval sys, user;
319 case CLOCK_REALTIME_PRECISE:
322 case CLOCK_REALTIME_FAST:
331 TIMEVAL_TO_TIMESPEC(&user, ats);
340 TIMEVAL_TO_TIMESPEC(&user, ats);
342 case CLOCK_MONOTONIC:
343 case CLOCK_MONOTONIC_PRECISE:
345 case CLOCK_UPTIME_PRECISE:
348 case CLOCK_UPTIME_FAST:
349 case CLOCK_MONOTONIC_FAST:
356 case CLOCK_THREAD_CPUTIME_ID:
359 case CLOCK_PROCESS_CPUTIME_ID:
365 if ((
int)clock_id >= 0)
372 #ifndef _SYS_SYSPROTO_H_
375 const struct timespec *
tp;
385 if ((error = copyin(uap->
tp, &ats,
sizeof(ats))) != 0)
396 if ((error =
priv_check(td, PRIV_CLOCK_SETTIME)) != 0)
398 if (clock_id != CLOCK_REALTIME)
400 if (ats->tv_nsec < 0 || ats->tv_nsec >= 1000000000)
403 TIMESPEC_TO_TIMEVAL(&atv, ats);
408 #ifndef _SYS_SYSPROTO_H_
425 error = copyout(&ts, uap->
tp,
sizeof(ts));
436 case CLOCK_REALTIME_FAST:
437 case CLOCK_REALTIME_PRECISE:
438 case CLOCK_MONOTONIC:
439 case CLOCK_MONOTONIC_FAST:
440 case CLOCK_MONOTONIC_PRECISE:
442 case CLOCK_UPTIME_FAST:
443 case CLOCK_UPTIME_PRECISE:
454 ts->tv_nsec = (1000000000 +
hz - 1) /
hz;
460 case CLOCK_THREAD_CPUTIME_ID:
461 case CLOCK_PROCESS_CPUTIME_ID:
465 if (ts->tv_nsec == 0)
469 if ((
int)clock_id < 0)
481 struct timespec ts, ts2, ts3;
485 if (rqt->tv_nsec < 0 || rqt->tv_nsec >= 1000000000)
487 if (rqt->tv_sec < 0 || (rqt->tv_sec == 0 && rqt->tv_nsec == 0))
490 timespecadd(&ts, rqt);
491 TIMESPEC_TO_TIMEVAL(&tv, rqt);
493 error = tsleep(&
nanowait, PWAIT | PCATCH,
"nanslp",
496 if (error != EWOULDBLOCK) {
497 if (error == ERESTART)
500 timespecsub(&ts, &ts2);
507 if (timespeccmp(&ts2, &ts, >=))
510 timespecsub(&ts3, &ts2);
511 TIMESPEC_TO_TIMEVAL(&tv, &ts3);
515 #ifndef _SYS_SYSPROTO_H_
525 struct timespec rmt, rqt;
528 error = copyin(uap->
rqtp, &rqt,
sizeof(rqt));
533 !useracc((caddr_t)uap->
rmtp,
sizeof(rmt), VM_PROT_WRITE))
536 if (error && uap->
rmtp) {
539 error2 = copyout(&rmt, uap->
rmtp,
sizeof(rmt));
546 #ifndef _SYS_SYSPROTO_H_
562 error = copyout(&atv, uap->
tp, sizeof (atv));
564 if (error == 0 && uap->
tzp != NULL) {
567 error = copyout(&rtz, uap->
tzp, sizeof (rtz));
572 #ifndef _SYS_SYSPROTO_H_
582 struct timeval atv, *tvp;
583 struct timezone atz, *tzp;
587 error = copyin(uap->
tv, &atv,
sizeof(atv));
594 error = copyin(uap->
tzp, &atz,
sizeof(atz));
613 if (tv->tv_usec < 0 || tv->tv_usec >= 1000000)
617 if (tzp && error == 0) {
645 #ifndef _SYS_SYSPROTO_H_
654 struct itimerval aitv;
660 return (copyout(&aitv, uap->
itv, sizeof (
struct itimerval)));
666 struct proc *p = td->td_proc;
669 if (which > ITIMER_PROF)
672 if (which == ITIMER_REAL) {
680 *aitv = p->p_realtimer;
682 if (timevalisset(&aitv->it_value)) {
684 if (timevalcmp(&aitv->it_value, &ctv, <))
685 timevalclear(&aitv->it_value);
691 *aitv = p->p_stats->p_timer[which];
697 #ifndef _SYS_SYSPROTO_H_
706 struct itimerval aitv, oitv;
709 if (uap->
itv == NULL) {
714 if ((error = copyin(uap->
itv, &aitv,
sizeof(
struct itimerval))))
717 if (error != 0 || uap->
oitv == NULL)
719 return (copyout(&oitv, uap->
oitv,
sizeof(
struct itimerval)));
724 struct itimerval *oitv)
726 struct proc *p = td->td_proc;
732 if (which > ITIMER_PROF)
736 if (!timevalisset(&aitv->it_value))
737 timevalclear(&aitv->it_interval);
741 if (which == ITIMER_REAL) {
743 if (timevalisset(&p->p_realtimer.it_value))
744 callout_stop(&p->p_itcallout);
746 if (timevalisset(&aitv->it_value)) {
747 callout_reset(&p->p_itcallout,
tvtohz(&aitv->it_value),
751 *oitv = p->p_realtimer;
752 p->p_realtimer = *aitv;
754 if (timevalisset(&oitv->it_value)) {
755 if (timevalcmp(&oitv->it_value, &ctv, <))
756 timevalclear(&oitv->it_value);
762 *oitv = p->p_stats->p_timer[which];
763 p->p_stats->p_timer[which] = *aitv;
785 struct timeval ctv, ntv;
787 p = (
struct proc *)arg;
789 if (!timevalisset(&p->p_realtimer.it_interval)) {
790 timevalclear(&p->p_realtimer.it_value);
791 if (p->p_flag & P_WEXIT)
797 &p->p_realtimer.it_interval);
799 if (timevalcmp(&p->p_realtimer.it_value, &ctv, >)) {
800 ntv = p->p_realtimer.it_value;
802 callout_reset(&p->p_itcallout,
tvtohz(&ntv) - 1,
820 if (tv->tv_sec < 0 || tv->tv_usec < 0 || tv->tv_usec >= 1000000)
822 if (tv->tv_sec == 0 && tv->tv_usec != 0 && tv->tv_usec <
tick)
841 if (itp->it_value.tv_usec < usec) {
842 if (itp->it_value.tv_sec == 0) {
844 usec -= itp->it_value.tv_usec;
847 itp->it_value.tv_usec += 1000000;
848 itp->it_value.tv_sec--;
850 itp->it_value.tv_usec -= usec;
852 if (timevalisset(&itp->it_value))
856 if (timevalisset(&itp->it_interval)) {
857 itp->it_value = itp->it_interval;
858 itp->it_value.tv_usec -= usec;
859 if (itp->it_value.tv_usec < 0) {
860 itp->it_value.tv_usec += 1000000;
861 itp->it_value.tv_sec--;
864 itp->it_value.tv_usec = 0;
879 t1->tv_sec += t2->tv_sec;
880 t1->tv_usec += t2->tv_usec;
888 t1->tv_sec -= t2->tv_sec;
889 t1->tv_usec -= t2->tv_usec;
897 if (t1->tv_usec < 0) {
899 t1->tv_usec += 1000000;
901 if (t1->tv_usec >= 1000000) {
903 t1->tv_usec -= 1000000;
911 ratecheck(
struct timeval *lasttime,
const struct timeval *mininterval)
913 struct timeval tv, delta;
924 if (timevalcmp(&delta, mininterval, >=) ||
925 (lasttime->tv_sec == 0 && lasttime->tv_usec == 0)) {
958 if (lasttime->tv_sec == 0 || (u_int)(now - lasttime->tv_sec) >=
hz) {
959 lasttime->tv_sec = now;
961 return (maxpps != 0);
964 return (maxpps < 0 || *curpps < maxpps);
971 struct kclock rt_clock = {
979 itimer_zone = uma_zcreate(
"itimer",
sizeof(
struct itimer),
987 (
void *)ITIMER_EV_EXIT, EVENTHANDLER_PRI_ANY);
989 (
void *)ITIMER_EV_EXEC, EVENTHANDLER_PRI_ANY);
996 printf(
"%s: invalid clockid\n", __func__);
1008 it = (
struct itimer *)mem;
1009 mtx_init(&it->it_mtx,
"itimer lock", NULL, MTX_DEF);
1018 it = (
struct itimer *)mem;
1026 mtx_assert(&it->it_mtx, MA_OWNED);
1034 mtx_assert(&it->it_mtx, MA_OWNED);
1035 KASSERT(it->it_usecount > 0, (
"invalid it_usecount"));
1037 if (--it->it_usecount == 0 && (it->it_flags & ITF_WANTED) != 0)
1041 #ifndef _SYS_SYSPROTO_H_
1051 struct sigevent *evp, ev;
1055 if (uap->
evp == NULL) {
1058 error = copyin(uap->
evp, &ev,
sizeof(ev));
1065 error = copyout(&
id, uap->
timerid,
sizeof(
int));
1074 int *timerid,
int preset_id)
1076 struct proc *p = td->td_proc;
1088 if (evp->sigev_notify != SIGEV_NONE &&
1089 evp->sigev_notify != SIGEV_SIGNAL &&
1090 evp->sigev_notify != SIGEV_THREAD_ID)
1092 if ((evp->sigev_notify == SIGEV_SIGNAL ||
1093 evp->sigev_notify == SIGEV_THREAD_ID) &&
1094 !_SIG_VALID(evp->sigev_signo))
1098 if (p->p_itimers == NULL)
1103 it->it_usecount = 0;
1105 timespecclear(&it->it_time.it_value);
1106 timespecclear(&it->it_time.it_interval);
1108 it->it_overrun_last = 0;
1109 it->it_clockid = clock_id;
1110 it->it_timerid = -1;
1112 ksiginfo_init(&it->it_ksi);
1113 it->it_ksi.ksi_flags |= KSI_INS | KSI_EXT;
1114 error =
CLOCK_CALL(clock_id, timer_create, (it));
1119 if (preset_id != -1) {
1120 KASSERT(preset_id >= 0 && preset_id < 3, (
"invalid preset_id"));
1122 if (p->p_itimers->its_timers[
id] != NULL) {
1132 for (
id = 3;
id < TIMER_MAX;
id++)
1133 if (p->p_itimers->its_timers[
id] == NULL)
1135 if (
id == TIMER_MAX) {
1141 it->it_timerid = id;
1142 p->p_itimers->its_timers[id] = it;
1144 it->it_sigev = *evp;
1146 it->it_sigev.sigev_notify = SIGEV_SIGNAL;
1149 case CLOCK_REALTIME:
1150 it->it_sigev.sigev_signo = SIGALRM;
1153 it->it_sigev.sigev_signo = SIGVTALRM;
1156 it->it_sigev.sigev_signo = SIGPROF;
1159 it->it_sigev.sigev_value.sival_int = id;
1162 if (it->it_sigev.sigev_notify == SIGEV_SIGNAL ||
1163 it->it_sigev.sigev_notify == SIGEV_THREAD_ID) {
1164 it->it_ksi.ksi_signo = it->it_sigev.sigev_signo;
1165 it->it_ksi.ksi_code = SI_TIMER;
1166 it->it_ksi.ksi_value = it->it_sigev.sigev_value;
1167 it->it_ksi.ksi_timerid = id;
1175 CLOCK_CALL(it->it_clockid, timer_delete, (it));
1181 #ifndef _SYS_SYSPROTO_H_
1193 static struct itimer *
1198 PROC_LOCK_ASSERT(p, MA_OWNED);
1199 if ((p->p_itimers == NULL) ||
1200 (timerid < 0) || (timerid >= TIMER_MAX) ||
1201 (it = p->p_itimers->its_timers[timerid]) == NULL) {
1205 if ((it->it_flags & ITF_DELETING) != 0) {
1215 struct proc *p = td->td_proc;
1226 it->it_flags |= ITF_DELETING;
1227 while (it->it_usecount > 0) {
1228 it->it_flags |= ITF_WANTED;
1229 msleep(it, &it->it_mtx, PPAUSE,
"itimer", 0);
1231 it->it_flags &= ~ITF_WANTED;
1232 CLOCK_CALL(it->it_clockid, timer_delete, (it));
1236 if (KSI_ONQ(&it->it_ksi))
1238 p->p_itimers->its_timers[timerid] = NULL;
1244 #ifndef _SYS_SYSPROTO_H_
1255 struct itimerspec val, oval, *ovalp;
1258 error = copyin(uap->
value, &val,
sizeof(val));
1261 ovalp = uap->
ovalue != NULL ? &oval : NULL;
1263 if (error == 0 && uap->
ovalue != NULL)
1264 error = copyout(ovalp, uap->
ovalue,
sizeof(*ovalp));
1270 struct itimerspec *val,
struct itimerspec *oval)
1278 if (timer_id < 3 || (it =
itimer_find(p, timer_id)) == NULL) {
1284 error =
CLOCK_CALL(it->it_clockid, timer_settime, (it,
1292 #ifndef _SYS_SYSPROTO_H_
1301 struct itimerspec val;
1306 error = copyout(&val, uap->
value,
sizeof(val));
1319 if (timer_id < 3 || (it =
itimer_find(p, timer_id)) == NULL) {
1325 error =
CLOCK_CALL(it->it_clockid, timer_gettime, (it, val));
1332 #ifndef _SYS_SYSPROTO_H_
1347 struct proc *p = td->td_proc;
1357 td->td_retval[0] = it->it_overrun_last;
1368 callout_init_mtx(&it->it_callout, &it->it_mtx, 0);
1375 mtx_assert(&it->it_mtx, MA_OWNED);
1381 timespecclear(&it->it_time.it_value);
1382 timespecclear(&it->it_time.it_interval);
1384 callout_drain(&it->it_callout);
1392 struct timespec cts;
1394 mtx_assert(&it->it_mtx, MA_OWNED);
1397 *ovalue = it->it_time;
1398 if (ovalue->it_value.tv_sec != 0 || ovalue->it_value.tv_nsec != 0) {
1399 timespecsub(&ovalue->it_value, &cts);
1400 if (ovalue->it_value.tv_sec < 0 ||
1401 (ovalue->it_value.tv_sec == 0 &&
1402 ovalue->it_value.tv_nsec == 0)) {
1403 ovalue->it_value.tv_sec = 0;
1404 ovalue->it_value.tv_nsec = 1;
1412 struct itimerspec *
value,
struct itimerspec *ovalue)
1414 struct timespec cts, ts;
1416 struct itimerspec val;
1418 mtx_assert(&it->it_mtx, MA_OWNED);
1424 if (timespecisset(&val.it_value)) {
1428 timespecclear(&val.it_interval);
1435 if (timespecisset(&val.it_value)) {
1438 if ((flags & TIMER_ABSTIME) == 0) {
1440 timespecadd(&it->it_time.it_value, &cts);
1442 timespecsub(&ts, &cts);
1448 TIMESPEC_TO_TIMEVAL(&tv, &ts);
1449 callout_reset(&it->it_callout,
tvtohz(&tv),
1452 callout_stop(&it->it_callout);
1461 if (
id == CLOCK_REALTIME)
1472 PROC_LOCK_ASSERT(p, MA_OWNED);
1475 ksi->ksi_overrun = it->it_overrun;
1476 it->it_overrun_last = it->it_overrun;
1488 if (ts->tv_sec < 0 || ts->tv_nsec < 0 || ts->tv_nsec >= 1000000000)
1490 if (ts->tv_sec == 0 && ts->tv_nsec != 0 && ts->tv_nsec <
tick * 1000)
1491 ts->tv_nsec =
tick * 1000;
1499 struct timespec cts, ts;
1503 it = (
struct itimer *)arg;
1507 if (timespeccmp(&cts, &it->it_time.it_value, >=)) {
1508 if (timespecisset(&it->it_time.it_interval)) {
1509 timespecadd(&it->it_time.it_value,
1510 &it->it_time.it_interval);
1511 while (timespeccmp(&cts, &it->it_time.it_value, >=)) {
1512 if (it->it_overrun < INT_MAX)
1515 it->it_ksi.ksi_errno = ERANGE;
1516 timespecadd(&it->it_time.it_value,
1517 &it->it_time.it_interval);
1521 timespecclear(&it->it_time.it_value);
1523 if (timespecisset(&it->it_time.it_value)) {
1524 ts = it->it_time.it_value;
1525 timespecsub(&ts, &cts);
1526 TIMESPEC_TO_TIMEVAL(&tv, &ts);
1527 callout_reset(&it->it_callout,
tvtohz(&tv),
1535 }
else if (timespecisset(&it->it_time.it_value)) {
1536 ts = it->it_time.it_value;
1537 timespecsub(&ts, &cts);
1538 TIMESPEC_TO_TIMEVAL(&tv, &ts);
1547 struct proc *p = it->it_proc;
1550 if (it->it_sigev.sigev_notify == SIGEV_SIGNAL ||
1551 it->it_sigev.sigev_notify == SIGEV_THREAD_ID) {
1554 timespecclear(&it->it_time.it_value);
1555 timespecclear(&it->it_time.it_interval);
1556 callout_stop(&it->it_callout);
1560 if (!KSI_ONQ(&it->it_ksi)) {
1561 it->it_ksi.ksi_errno = 0;
1562 ksiginfo_set_sigev(&it->it_ksi, &it->it_sigev);
1563 tdsendsignal(p, td, it->it_ksi.ksi_signo, &it->it_ksi);
1565 if (it->it_overrun < INT_MAX)
1568 it->it_ksi.ksi_errno = ERANGE;
1577 struct itimers *its;
1580 its =
malloc(
sizeof (
struct itimers), M_SUBPROC, M_WAITOK | M_ZERO);
1581 LIST_INIT(&its->its_virtual);
1582 LIST_INIT(&its->its_prof);
1583 TAILQ_INIT(&its->its_worklist);
1584 for (i = 0; i < TIMER_MAX; i++)
1585 its->its_timers[i] = NULL;
1587 if (p->p_itimers == NULL) {
1593 free(its, M_SUBPROC);
1607 struct itimers *its;
1609 int event = (int)(intptr_t)arg;
1612 if (p->p_itimers != NULL) {
1622 if (event == ITIMER_EV_EXEC)
1624 else if (event == ITIMER_EV_EXIT)
1627 panic(
"unhandled event");
1628 for (; i < TIMER_MAX; ++i) {
1629 if ((it = its->its_timers[i]) != NULL)
1632 if (its->its_timers[0] == NULL &&
1633 its->its_timers[1] == NULL &&
1634 its->its_timers[2] == NULL) {
1635 free(its, M_SUBPROC);
1636 p->p_itimers = NULL;
int kern_setitimer(struct thread *td, u_int which, struct itimerval *aitv, struct itimerval *oitv)
int tvtohz(struct timeval *tv)
void rufetch(struct proc *p, struct rusage *ru)
volatile time_t time_second
static void itimers_alloc(struct proc *)
static void realtimer_clocktime(clockid_t, struct timespec *)
int kern_clock_getcpuclockid2(struct thread *td, id_t id, int which, clockid_t *clk_id)
int sys_getitimer(struct thread *td, struct getitimer_args *uap)
int ppsratecheck(struct timeval *lasttime, int *curpps, int maxpps)
#define MAKE_THREAD_CPUCLOCK(tid)
void * malloc(unsigned long size, struct malloc_type *mtp, int flags)
static uma_zone_t itimer_zone
struct itimerspec * ovalue
void sigqueue_take(ksiginfo_t *ksi)
static void itimer_start(void)
void panic(const char *fmt,...)
static int realtimer_gettime(struct itimer *, struct itimerspec *)
int itimespecfix(struct timespec *ts)
int sys_ktimer_gettime(struct thread *td, struct ktimer_gettime_args *uap)
void realitexpire(void *arg)
static void get_thread_cputime(struct thread *targettd, struct timespec *ats)
int kern_clock_getres(struct thread *td, clockid_t clock_id, struct timespec *ts)
int sys_ktimer_delete(struct thread *td, struct ktimer_delete_args *uap)
int sys_setitimer(struct thread *td, struct setitimer_args *uap)
int sys_nanosleep(struct thread *td, struct nanosleep_args *uap)
const struct timespec * tp
static void itimers_event_hook_exit(void *arg, struct proc *p)
void kern_psignal(struct proc *p, int sig)
const struct itimerspec * value
void getnanouptime(struct timespec *tsp)
int sys_ktimer_settime(struct thread *td, struct ktimer_settime_args *uap)
void getmicrouptime(struct timeval *tvp)
static int get_cputime(struct thread *td, clockid_t clock_id, struct timespec *ats)
void timevalsub(struct timeval *t1, const struct timeval *t2)
int priv_check(struct thread *td, int priv)
void itimer_fire(struct itimer *it)
int register_posix_clock(int, struct kclock *)
static void itimer_fini(void *, int)
int ratecheck(struct timeval *lasttime, const struct timeval *mininterval)
static int realtimer_delete(struct itimer *)
static void get_process_cputime(struct proc *targetp, struct timespec *ats)
void p31b_setcfg(int num, int value)
int kern_getitimer(struct thread *td, u_int which, struct itimerval *aitv)
uint64_t cputick2usec(uint64_t tick)
static void itimer_leave(struct itimer *)
void tc_setclock(struct timespec *ts)
int sys_settimeofday(struct thread *td, struct settimeofday_args *uap)
int sys_gettimeofday(struct thread *td, struct gettimeofday_args *uap)
static void timevalfix(struct timeval *)
int kern_settimeofday(struct thread *td, struct timeval *tv, struct timezone *tzp)
int itimerdecr(struct itimerval *itp, int usec)
static struct itimer * itimer_find(struct proc *, int)
static int settime(struct thread *, struct timeval *)
void timevaladd(struct timeval *t1, const struct timeval *t2)
int sys_clock_getcpuclockid2(struct thread *td, struct clock_getcpuclockid2_args *uap)
#define MAKE_PROCESS_CPUCLOCK(pid)
int sigev_findtd(struct proc *p, struct sigevent *sigev, struct thread **ttd)
void nanotime(struct timespec *tsp)
struct itimerspec * value
static int realtimer_create(struct itimer *)
static void itimers_event_hook_exec(void *arg, struct proc *p, struct image_params *imgp)
static int itimer_init(void *, int, int)
int sys_clock_getres(struct thread *td, struct clock_getres_args *uap)
static int realtimer_settime(struct itimer *, int, struct itimerspec *, struct itimerspec *)
void getnanotime(struct timespec *tsp)
int sys_clock_settime(struct thread *td, struct clock_settime_args *uap)
void free(void *addr, struct malloc_type *mtp)
#define CLOCK_CALL(clock, call, arglist)
int kern_nanosleep(struct thread *td, struct timespec *rqt, struct timespec *rmt)
static void itimer_enter(struct itimer *)
int printf(const char *fmt,...)
int sys_ktimer_getoverrun(struct thread *td, struct ktimer_getoverrun_args *uap)
int sys_clock_gettime(struct thread *td, struct clock_gettime_args *uap)
int kern_ktimer_getoverrun(struct thread *td, int timer_id)
SYSINIT(posix_timer, SI_SUB_P1003_1B, SI_ORDER_FIRST+4, itimer_start, NULL)
void mtx_init(struct mtx *m, const char *name, const char *type, int opts)
int itimer_accept(struct proc *p, int timerid, ksiginfo_t *ksi)
int kern_clock_gettime(struct thread *td, clockid_t clock_id, struct timespec *ats)
int kern_ktimer_create(struct thread *td, clockid_t clock_id, struct sigevent *evp, int *timerid, int preset_id)
static void cputick2timespec(uint64_t runtime, struct timespec *ats)
int kern_ktimer_gettime(struct thread *td, int timer_id, struct itimerspec *val)
int pget(pid_t pid, int flags, struct proc **pp)
static void realtimer_expire(void *)
int itimerfix(struct timeval *tv)
uint64_t cpu_tickrate(void)
int tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi)
uint64_t tc_getfrequency(void)
int securelevel_gt(struct ucred *cr, int level)
int kern_ktimer_settime(struct thread *td, int timer_id, int flags, struct itimerspec *val, struct itimerspec *oval)
int sys_ktimer_create(struct thread *td, struct ktimer_create_args *uap)
void microtime(struct timeval *tvp)
struct thread * tdfind(lwpid_t tid, pid_t pid)
void calcru(struct proc *p, struct timeval *up, struct timeval *sp)
void mtx_destroy(struct mtx *m)
void nanouptime(struct timespec *tsp)
#define CPUCLOCK_PROCESS_BIT
int kern_ktimer_delete(struct thread *td, int timerid)
static struct kclock posix_clocks[MAX_CLOCKS]
void critical_enter(void)
int kern_clock_settime(struct thread *td, clockid_t clock_id, struct timespec *ats)