Lines Matching defs:it

51  * may _only_ be tuned in /etc/system or by patching the kernel binary; it
58 * ITLK_REMOVE bit; it's up to callers to look at this if they need to
59 * care. p_lock must be held on entry; it may be dropped and reaquired,
62 * Note that timer_create() doesn't call timer_lock(); it creates timers
66 timer_lock(proc_t *p, itimer_t *it)
70 while (it->it_lock & ITLK_LOCKED) {
71 it->it_blockers++;
72 cv_wait(&it->it_cv, &p->p_lock);
73 it->it_blockers--;
76 it->it_lock |= ITLK_LOCKED;
81 * waiters. p_lock must be held on entry; it will not be dropped by
85 timer_unlock(proc_t *p, itimer_t *it)
88 ASSERT(it->it_lock & ITLK_LOCKED);
89 it->it_lock &= ~ITLK_LOCKED;
90 cv_signal(&it->it_cv);
106 timer_delete_locked(proc_t *p, timer_t tid, itimer_t *it)
109 ASSERT(!(it->it_lock & ITLK_REMOVE));
110 ASSERT(it->it_lock & ITLK_LOCKED);
112 it->it_lock |= ITLK_REMOVE;
120 while (it->it_blockers) {
121 timer_unlock(p, it);
122 cv_wait(&it->it_cv, &p->p_lock);
123 timer_lock(p, it);
126 ASSERT(p->p_itimer[tid] == it);
131 * p_itimer[tid] to be NULL; no one can find it). Now we call into
132 * the clock backend to delete the timer; it is up to the backend to
138 it->it_backend->clk_timer_delete(it);
140 if (it->it_portev) {
141 mutex_enter(&it->it_mutex);
142 if (it->it_portev) {
145 (void) port_dissociate_ksource(it->it_portfd,
146 PORT_SOURCE_TIMER, (port_source_t *)it->it_portsrc);
147 pev = (port_kevent_t *)it->it_portev;
148 it->it_portev = NULL;
149 it->it_flags &= ~IT_PORT;
150 it->it_pending = 0;
151 mutex_exit(&it->it_mutex);
155 mutex_exit(&it->it_mutex);
167 if (it->it_pending > 0) {
168 it->it_sigq->sq_func = NULL;
170 kmem_free(it->it_sigq, sizeof (sigqueue_t));
173 ASSERT(it->it_blockers == 0);
174 kmem_cache_free(clock_timer_cache, it);
188 * If timer_grab() fails, it will return NULL. timer_grab() will fail if
202 itimer_t **itp, *it;
209 if ((itp = p->p_itimer) == NULL || (it = itp[tid]) == NULL) {
214 timer_lock(p, it);
216 if (it->it_lock & ITLK_REMOVE) {
218 * Someone is removing this timer; it will soon be invalid.
220 timer_unlock(p, it);
227 return (it);
233 * will drop it before returning.
236 timer_release(proc_t *p, itimer_t *it)
239 timer_unlock(p, it);
246 * p_lock, but will drop it before returning.
249 timer_delete_grabbed(proc_t *p, timer_t tid, itimer_t *it)
252 timer_delete_locked(p, tid, it);
392 itimer_t *it = (itimer_t *)sigq->sq_backptr;
400 mutex_enter(&it->it_mutex);
401 ASSERT(it->it_pending > 0);
402 it->it_overrun = it->it_pending - 1;
403 it->it_pending = 0;
404 mutex_exit(&it->it_mutex);
411 timer_fire(itimer_t *it)
416 if (it->it_flags & IT_SIGNAL) {
418 * See the comment in timer_signal() for why it is not
424 p = it->it_proc;
435 * We don't need to use the p_lock because it is only
445 mutex_enter(&it->it_mutex);
447 if (it->it_pending > 0) {
448 if (it->it_pending < INT_MAX)
449 it->it_pending++;
450 mutex_exit(&it->it_mutex);
452 if (it->it_flags & IT_PORT) {
453 it->it_pending = 1;
454 port_send_event((port_kevent_t *)it->it_portev);
455 mutex_exit(&it->it_mutex);
456 } else if (it->it_flags & IT_SIGNAL) {
457 it->it_pending = 1;
458 mutex_exit(&it->it_mutex);
459 sigaddqa(p, NULL, it->it_sigq);
461 mutex_exit(&it->it_mutex);
475 itimer_t *it, **itp;
553 it = kmem_cache_alloc(clock_timer_cache, KM_SLEEP);
554 bzero(it, sizeof (itimer_t));
555 mutex_init(&it->it_mutex, NULL, MUTEX_DEFAULT, NULL);
588 kmem_cache_free(clock_timer_cache, it);
612 sigq->sq_backptr = it;
613 it->it_sigq = sigq;
614 it->it_backend = backend;
615 it->it_lock = ITLK_LOCKED;
616 itp[i] = it;
626 * - allocate a port event structure and prepare it to be sent
640 it->it_flags |= IT_PORT;
645 (port_source_t **)&it->it_portsrc, timer_close_port,
646 (void *)it, NULL);
650 kmem_cache_free(clock_timer_cache, it);
660 (port_source_t *)it->it_portsrc);
663 kmem_cache_free(clock_timer_cache, it);
670 timer_port_callback, it);
671 it->it_portev = pkevp;
672 it->it_portfd = port;
675 it->it_flags |= IT_SIGNAL;
684 if ((error = backend->clk_timer_create(it, timer_fire)) != 0)
687 it->it_lwp = ttolwp(curthread);
688 it->it_proc = p;
699 timer_release(p, it);
707 * Since we never unlocked the timer (it was born locked), it's
710 ASSERT(!(it->it_lock & ITLK_REMOVE));
711 timer_delete_grabbed(p, i, it);
720 itimer_t *it;
724 if ((it = timer_grab(p, tid)) == NULL)
727 error = it->it_backend->clk_timer_gettime(it, &when);
729 timer_release(p, it);
755 itimer_t *it;
782 if ((it = timer_grab(p, tid)) == NULL)
785 error = it->it_backend->clk_timer_settime(it, flags, &when);
787 timer_release(p, it);
796 itimer_t *it;
798 if ((it = timer_grab(p, tid)) == NULL)
801 timer_delete_grabbed(p, tid, it);
811 itimer_t *it;
813 if ((it = timer_grab(p, tid)) == NULL)
818 * it before looking at the value.
821 overrun = it->it_overrun;
824 timer_release(p, it);
838 itimer_t *it, **itp;
846 if ((it = itp[i]) == NULL)
849 timer_lock(p, it);
851 if ((it->it_lock & ITLK_REMOVE) || it->it_lwp != lwp) {
853 * This timer is either being removed or it isn't
856 timer_unlock(p, it);
867 it->it_lwp = NULL;
868 timer_unlock(p, it);
882 itimer_t *it, **itp;
890 if ((it = itp[i]) == NULL)
893 timer_lock(p, it);
895 if (!(it->it_lock & ITLK_REMOVE) && it->it_lwp == lwp) {
900 it->it_backend->clk_timer_lwpbind(it);
904 timer_unlock(p, it);
937 itimer_t *it = arg;
939 mutex_enter(&it->it_mutex);
940 if (curproc != it->it_proc) {
942 mutex_exit(&it->it_mutex);
945 *events = it->it_pending; /* 1 = 1 event, >1 # of overflows */
946 it->it_pending = 0; /* reinit overflow counter */
957 mutex_exit(&it->it_mutex);
964 * the port and it is not useable in this case.
975 itimer_t *it;
978 if ((it = timer_grab(p, tid)) == NULL)
980 if (it->it_portev) {
981 mutex_enter(&it->it_mutex);
982 if (it->it_portfd == port) {
984 pev = (port_kevent_t *)it->it_portev;
985 it->it_portev = NULL;
986 it->it_flags &= ~IT_PORT;
987 mutex_exit(&it->it_mutex);
991 mutex_exit(&it->it_mutex);
994 timer_release(p, it);