Lines Matching refs:it

106 static void	realtimer_expire_l(struct itimer *it, bool proc_locked);
111 static void itimer_fire(struct itimer *it);
720 * as a delta, so that it is easy to keep periodic real-time signals from
726 * real time due to interrupt processing in the system, it is possible for
728 * in real time past when it is supposed to occur. It does not suffice,
896 struct itimer *it;
912 it = p->p_itimers->its_timers[id];
913 if (it == NULL)
915 if ((it->it_flags & ITF_PSTOPPED) != 0) {
916 ITIMER_LOCK(it);
917 if ((it->it_flags & ITF_PSTOPPED) != 0) {
918 it->it_flags &= ~ITF_PSTOPPED;
919 if ((it->it_flags & ITF_DELETING) == 0)
920 realtimer_expire_l(it, true);
922 ITIMER_UNLOCK(it);
976 * fix it to have at least minimal value (i.e. if it is less
977 * than the resolution of the clock, round it up.)
995 * it. In this case, carry over (usec - old value) to
998 * that it is called in a context where the timers
999 * on which it is operating cannot change in value.
1036 * it just gets very confused in this case.
1165 struct itimer *it;
1167 it = (struct itimer *)mem;
1168 mtx_init(&it->it_mtx, "itimer lock", NULL, MTX_DEF);
1175 struct itimer *it;
1177 it = (struct itimer *)mem;
1178 mtx_destroy(&it->it_mtx);
1182 itimer_enter(struct itimer *it)
1185 mtx_assert(&it->it_mtx, MA_OWNED);
1186 it->it_usecount++;
1190 itimer_leave(struct itimer *it)
1193 mtx_assert(&it->it_mtx, MA_OWNED);
1194 KASSERT(it->it_usecount > 0, ("invalid it_usecount"));
1196 if (--it->it_usecount == 0 && (it->it_flags & ITF_WANTED) != 0)
1197 wakeup(it);
1236 struct itimer *it;
1260 it = uma_zalloc(itimer_zone, M_WAITOK);
1261 it->it_flags = 0;
1262 it->it_usecount = 0;
1263 timespecclear(&it->it_time.it_value);
1264 timespecclear(&it->it_time.it_interval);
1265 it->it_overrun = 0;
1266 it->it_overrun_last = 0;
1267 it->it_clockid = clock_id;
1268 it->it_proc = p;
1269 ksiginfo_init(&it->it_ksi);
1270 it->it_ksi.ksi_flags |= KSI_INS | KSI_EXT;
1271 error = CLOCK_CALL(clock_id, timer_create, (it));
1298 p->p_itimers->its_timers[id] = it;
1300 it->it_sigev = *evp;
1302 it->it_sigev.sigev_notify = SIGEV_SIGNAL;
1306 it->it_sigev.sigev_signo = SIGALRM;
1309 it->it_sigev.sigev_signo = SIGVTALRM;
1312 it->it_sigev.sigev_signo = SIGPROF;
1315 it->it_sigev.sigev_value.sival_int = id;
1318 if (it->it_sigev.sigev_notify == SIGEV_SIGNAL ||
1319 it->it_sigev.sigev_notify == SIGEV_THREAD_ID) {
1320 it->it_ksi.ksi_signo = it->it_sigev.sigev_signo;
1321 it->it_ksi.ksi_code = SI_TIMER;
1322 it->it_ksi.ksi_value = it->it_sigev.sigev_value;
1323 it->it_ksi.ksi_timerid = id;
1330 ITIMER_LOCK(it);
1331 CLOCK_CALL(it->it_clockid, timer_delete, (it));
1332 ITIMER_UNLOCK(it);
1333 uma_zfree(itimer_zone, it);
1352 struct itimer *it;
1357 (it = p->p_itimers->its_timers[timerid]) == NULL) {
1360 ITIMER_LOCK(it);
1361 if ((it->it_flags & ITF_DELETING) != 0) {
1362 ITIMER_UNLOCK(it);
1363 it = NULL;
1365 return (it);
1372 struct itimer *it;
1375 it = itimer_find(p, timerid);
1376 if (it == NULL) {
1382 it->it_flags |= ITF_DELETING;
1383 while (it->it_usecount > 0) {
1384 it->it_flags |= ITF_WANTED;
1385 msleep(it, &it->it_mtx, PPAUSE, "itimer", 0);
1387 it->it_flags &= ~ITF_WANTED;
1388 CLOCK_CALL(it->it_clockid, timer_delete, (it));
1389 ITIMER_UNLOCK(it);
1392 if (KSI_ONQ(&it->it_ksi))
1393 sigqueue_take(&it->it_ksi);
1396 uma_zfree(itimer_zone, it);
1429 struct itimer *it;
1434 if (timer_id < 3 || (it = itimer_find(p, timer_id)) == NULL) {
1439 itimer_enter(it);
1440 error = CLOCK_CALL(it->it_clockid, timer_settime, (it,
1442 itimer_leave(it);
1443 ITIMER_UNLOCK(it);
1470 struct itimer *it;
1475 if (timer_id < 3 || (it = itimer_find(p, timer_id)) == NULL) {
1480 itimer_enter(it);
1481 error = CLOCK_CALL(it->it_clockid, timer_gettime, (it, val));
1482 itimer_leave(it);
1483 ITIMER_UNLOCK(it);
1504 struct itimer *it;
1509 (it = itimer_find(p, timer_id)) == NULL) {
1513 td->td_retval[0] = it->it_overrun_last;
1514 ITIMER_UNLOCK(it);
1522 realtimer_create(struct itimer *it)
1524 callout_init_mtx(&it->it_callout, &it->it_mtx, 0);
1529 realtimer_delete(struct itimer *it)
1531 mtx_assert(&it->it_mtx, MA_OWNED);
1537 timespecclear(&it->it_time.it_value);
1538 timespecclear(&it->it_time.it_interval);
1539 ITIMER_UNLOCK(it);
1540 callout_drain(&it->it_callout);
1541 ITIMER_LOCK(it);
1546 realtimer_gettime(struct itimer *it, struct itimerspec *ovalue)
1550 mtx_assert(&it->it_mtx, MA_OWNED);
1552 realtimer_clocktime(it->it_clockid, &cts);
1553 *ovalue = it->it_time;
1567 realtimer_settime(struct itimer *it, int flags, struct itimerspec *value,
1574 mtx_assert(&it->it_mtx, MA_OWNED);
1588 realtimer_gettime(it, ovalue);
1590 it->it_time = val;
1592 realtimer_clocktime(it->it_clockid, &cts);
1596 timespecadd(&it->it_time.it_value, &cts,
1597 &it->it_time.it_value);
1602 * fix it.
1606 callout_reset(&it->it_callout, tvtohz(&tv), realtimer_expire,
1607 it);
1609 callout_stop(&it->it_callout);
1627 struct itimer *it;
1630 it = itimer_find(p, timerid);
1631 if (it != NULL) {
1632 ksi->ksi_overrun = it->it_overrun;
1633 it->it_overrun_last = it->it_overrun;
1634 it->it_overrun = 0;
1635 ITIMER_UNLOCK(it);
1662 realtimer_expire_l(struct itimer *it, bool proc_locked)
1669 realtimer_clocktime(it->it_clockid, &cts);
1671 if (timespeccmp(&cts, &it->it_time.it_value, >=)) {
1672 if (timespecisset(&it->it_time.it_interval)) {
1673 timespecadd(&it->it_time.it_value,
1674 &it->it_time.it_interval,
1675 &it->it_time.it_value);
1677 interval = timespectons(&it->it_time.it_interval);
1678 value = timespectons(&it->it_time.it_value);
1686 if (it->it_overrun + overruns >=
1687 it->it_overrun &&
1688 it->it_overrun + overruns <= INT_MAX) {
1689 it->it_overrun += (int)overruns;
1691 it->it_overrun = INT_MAX;
1692 it->it_ksi.ksi_errno = ERANGE;
1696 it->it_time.it_value = timespecfromns(value);
1700 timespecclear(&it->it_time.it_value);
1703 p = it->it_proc;
1704 if (timespecisset(&it->it_time.it_value)) {
1706 it->it_flags |= ITF_PSTOPPED;
1708 timespecsub(&it->it_time.it_value, &cts, &ts);
1710 callout_reset(&it->it_callout, tvtohz(&tv),
1711 realtimer_expire, it);
1715 itimer_enter(it);
1716 ITIMER_UNLOCK(it);
1719 itimer_fire(it);
1722 ITIMER_LOCK(it);
1723 itimer_leave(it);
1724 } else if (timespecisset(&it->it_time.it_value)) {
1725 p = it->it_proc;
1727 it->it_flags |= ITF_PSTOPPED;
1729 ts = it->it_time.it_value;
1732 callout_reset(&it->it_callout, tvtohz(&tv),
1733 realtimer_expire, it);
1746 itimer_fire(struct itimer *it)
1748 struct proc *p = it->it_proc;
1751 if (it->it_sigev.sigev_notify == SIGEV_SIGNAL ||
1752 it->it_sigev.sigev_notify == SIGEV_THREAD_ID) {
1753 if (sigev_findtd(p, &it->it_sigev, &td) != 0) {
1754 ITIMER_LOCK(it);
1755 timespecclear(&it->it_time.it_value);
1756 timespecclear(&it->it_time.it_interval);
1757 callout_stop(&it->it_callout);
1758 ITIMER_UNLOCK(it);
1761 if (!KSI_ONQ(&it->it_ksi)) {
1762 it->it_ksi.ksi_errno = 0;
1763 ksiginfo_set_sigev(&it->it_ksi, &it->it_sigev);
1764 tdsendsignal(p, td, it->it_ksi.ksi_signo, &it->it_ksi);
1766 if (it->it_overrun < INT_MAX)
1767 it->it_overrun++;
1769 it->it_ksi.ksi_errno = ERANGE;
1797 struct itimer *it;
1805 if ((it = its->its_timers[i]) != NULL)