Lines Matching defs:it

137 	 * Don't allow the time to be set forward so far it
142 * past the cutoff, it will take a very long time
231 * comparatively less often than timers firing, and so it's better
235 struct itimer *it;
237 LIST_FOREACH(it, &itimer_realtime_changed_notify, it_rtchgq) {
238 KASSERT(it->it_ops->ito_realtime_changed != NULL);
239 if (timespecisset(&it->it_time.it_value)) {
240 (*it->it_ops->ito_realtime_changed)(it);
527 * fake up a timezone struct and return it if demanded.
561 * obsolete program would try to set it, so we log a warning.
666 * to interrupt processing on the system, it is possible for the real
684 itimer_init(struct itimer * const it, const struct itimer_ops * const ops,
691 timespecclear(&it->it_time.it_value);
692 it->it_ops = ops;
693 it->it_clockid = id;
694 it->it_overruns = 0;
695 it->it_dying = false;
698 callout_init(&it->it_ch, CALLOUT_MPSAFE);
699 callout_setfunc(&it->it_ch, itimer_callout, it);
702 it, it_rtchgq);
706 it->it_vlist = itl;
707 it->it_active = false;
714 * Poison an interval timer, preventing it from being scheduled
718 itimer_poison(struct itimer * const it)
723 it->it_dying = true;
726 * For non-virtual timers, stop the callout, or wait for it to
727 * run if it has already fired. It cannot restart again after
729 * other users holding the lock can restart it, and any other
733 if (!CLOCK_VIRTUAL_P(it->it_clockid)) {
734 callout_halt(&it->it_ch, &itimer_mutex);
735 if (it->it_clockid == CLOCK_REALTIME &&
736 it->it_ops->ito_realtime_changed != NULL) {
737 LIST_REMOVE(it, it_rtchgq);
750 itimer_fini(struct itimer * const it)
759 if (!CLOCK_VIRTUAL_P(it->it_clockid))
760 callout_destroy(&it->it_ch);
768 * expires, then reload it. In this case, carry over (nsec - old value)
770 * not drift. This routine assumes that it is called in a context where
771 * the timers on which it is operating cannot change in value.
776 itimer_decr(struct itimer *it, int nsec)
782 KASSERT(CLOCK_VIRTUAL_P(it->it_clockid));
784 itp = &it->it_time;
807 error = itimer_settime(it);
820 itimer_arm_real(struct itimer * const it)
823 KASSERT(!it->it_dying);
824 KASSERT(!CLOCK_VIRTUAL_P(it->it_clockid));
825 KASSERT(!callout_pending(&it->it_ch));
829 * callout_schedule() does it for us.
831 callout_schedule(&it->it_ch,
832 (it->it_clockid == CLOCK_MONOTONIC
833 ? tshztoup(&it->it_time.it_value)
834 : tshzto(&it->it_time.it_value)));
840 * Callout to expire a non-virtual timer. Queue it up for processing,
841 * and then reload, if it is configured to do so.
850 struct itimer * const it = arg;
854 (*it->it_ops->ito_fire)(it);
856 if (!timespecisset(&it->it_time.it_interval)) {
857 timespecclear(&it->it_time.it_value);
862 if (it->it_clockid == CLOCK_MONOTONIC) {
872 itimer_transition(&it->it_time, &now, &next, &overruns);
873 it->it_time.it_value = next;
874 it->it_overruns += overruns;
877 * Reset the callout, if it's not going away.
879 if (!it->it_dying)
880 itimer_arm_real(it);
887 * Set up the given interval timer. The value in it->it_time.it_value
894 * Caller is responsible for validating it->it_value and
895 * it->it_interval, e.g. with itimerfix or itimespecfix.
898 itimer_settime(struct itimer *it)
904 KASSERT(!it->it_dying);
905 KASSERT(it->it_time.it_value.tv_sec >= 0);
906 KASSERT(it->it_time.it_value.tv_nsec >= 0);
907 KASSERT(it->it_time.it_value.tv_nsec < 1000000000);
908 KASSERT(it->it_time.it_interval.tv_sec >= 0);
909 KASSERT(it->it_time.it_interval.tv_nsec >= 0);
910 KASSERT(it->it_time.it_interval.tv_nsec < 1000000000);
912 if (!CLOCK_VIRTUAL_P(it->it_clockid)) {
914 * Try to stop the callout. However, if it had already
915 * fired, we have to drop the lock to wait for it, so
920 if (callout_halt(&it->it_ch, &itimer_mutex))
922 KASSERT(!it->it_dying);
924 /* Now we can touch it and start it up again. */
925 if (timespecisset(&it->it_time.it_value))
926 itimer_arm_real(it);
928 if (it->it_active) {
929 itn = LIST_NEXT(it, it_list);
930 LIST_REMOVE(it, it_list);
932 timespecadd(&it->it_time.it_value,
936 if (timespecisset(&it->it_time.it_value)) {
937 itl = it->it_vlist;
939 itn && timespeccmp(&it->it_time.it_value,
942 timespecsub(&it->it_time.it_value,
944 &it->it_time.it_value);
947 LIST_INSERT_AFTER(pitn, it, it_list);
949 LIST_INSERT_HEAD(itl, it, it_list);
953 &it->it_time.it_value,
956 it->it_active = true;
958 it->it_active = false;
972 itimer_gettime(const struct itimer *it, struct itimerspec *aits)
978 KASSERT(!it->it_dying);
980 *aits = it->it_time;
981 if (!CLOCK_VIRTUAL_P(it->it_clockid)) {
990 if (it->it_clockid == CLOCK_REALTIME) {
1001 } else if (it->it_active) {
1002 for (itn = LIST_FIRST(it->it_vlist); itn && itn != it;
1006 KASSERT(itn != NULL); /* it should be findable on the list */
1035 struct itimer *it;
1040 it = pts->pts_timers[index];
1041 pt = container_of(it, struct ptimer, pt_itimer);
1043 itimer_poison(it);
1046 * Remove it from the queue to be signalled. Must be done
1055 itimer_fini(it); /* releases itimer_lock */
1095 * This function is exported because it is needed in the exec and
1168 ptimer_fire(struct itimer *it)
1170 struct ptimer *pt = container_of(it, struct ptimer, pt_itimer);
1313 struct itimer *it, *itn;
1322 if ((it = pts->pts_timers[timerid]) == NULL) {
1327 if (CLOCK_VIRTUAL_P(it->it_clockid)) {
1328 if (it->it_active) {
1329 itn = LIST_NEXT(it, it_list);
1330 LIST_REMOVE(it, it_list);
1332 timespecadd(&it->it_time.it_value,
1335 it->it_active = false;
1388 struct itimer *it;
1402 if ((it = pts->pts_timers[timerid]) == NULL) {
1408 itimer_gettime(it, ovalue);
1409 it->it_time = val;
1413 * convert it to absolute; if an absolute time for a virtual
1414 * timer, convert it to relative and make sure we don't set it
1415 * to zero, which would cancel the timer, or let it go
1418 if (timespecisset(&it->it_time.it_value)) {
1419 if (!CLOCK_VIRTUAL_P(it->it_clockid)) {
1421 if (it->it_clockid == CLOCK_REALTIME) {
1426 timespecadd(&it->it_time.it_value, &now,
1427 &it->it_time.it_value);
1432 timespecsub(&it->it_time.it_value, &now,
1433 &it->it_time.it_value);
1434 if (!timespecisset(&it->it_time.it_value) ||
1435 it->it_time.it_value.tv_sec < 0) {
1436 it->it_time.it_value.tv_sec = 0;
1437 it->it_time.it_value.tv_nsec = 1;
1443 error = itimer_settime(it);
1445 KASSERT(!CLOCK_VIRTUAL_P(it->it_clockid));
1480 struct itimer *it;
1487 if ((it = pts->pts_timers[timerid]) == NULL) {
1491 itimer_gettime(it, its);
1514 struct itimer *it;
1523 if ((it = pts->pts_timers[timerid]) == NULL) {
1527 pt = container_of(it, struct ptimer, pt_itimer);
1564 struct itimer *it;
1572 if (pts == NULL || (it = pts->pts_timers[which]) == NULL) {
1576 itimer_gettime(it, &its);
1628 struct itimer *it;
1651 it = pts->pts_timers[which];
1652 if (it == NULL) {
1663 it = &pt->pt_itimer;
1684 itimer_init(it, &ptimer_itimer_ops, which, itl);
1688 pts->pts_timers[which] = it;
1691 TIMEVAL_TO_TIMESPEC(&itvp->it_value, &it->it_time.it_value);
1692 TIMEVAL_TO_TIMESPEC(&itvp->it_interval, &it->it_time.it_interval);
1695 if (timespecisset(&it->it_time.it_value)) {
1701 if (!timespecaddok(&it->it_time.it_value, &now)) {
1705 timespecadd(&it->it_time.it_value, &now,
1706 &it->it_time.it_value);
1710 if (!timespecaddok(&it->it_time.it_value, &now)) {
1714 timespecadd(&it->it_time.it_value, &now,
1715 &it->it_time.it_value);
1722 error = itimer_settime(it);
1724 KASSERT(!CLOCK_VIRTUAL_P(it->it_clockid));
1745 struct itimer *it;
1757 if (user && (it = LIST_FIRST(&pts->pts_virtual)) != NULL)
1758 if (itimer_decr(it, tick * 1000))
1759 (*it->it_ops->ito_fire)(it);
1760 if ((it = LIST_FIRST(&pts->pts_prof)) != NULL)
1761 if (itimer_decr(it, tick * 1000))
1762 (*it->it_ops->ito_fire)(it);
1777 struct itimer *it;
1784 it = &pt->pt_itimer;
1799 it->it_overruns++;
1807 pt->pt_poverruns = it->it_overruns;
1808 it->it_overruns = 0;