Lines Matching refs:it
66 timer_lock(proc_t *p, itimer_t *it) in timer_lock() argument
70 while (it->it_lock & ITLK_LOCKED) { in timer_lock()
71 it->it_blockers++; in timer_lock()
72 cv_wait(&it->it_cv, &p->p_lock); in timer_lock()
73 it->it_blockers--; in timer_lock()
76 it->it_lock |= ITLK_LOCKED; in timer_lock()
85 timer_unlock(proc_t *p, itimer_t *it) in timer_unlock() argument
88 ASSERT(it->it_lock & ITLK_LOCKED); in timer_unlock()
89 it->it_lock &= ~ITLK_LOCKED; in timer_unlock()
90 cv_signal(&it->it_cv); in timer_unlock()
106 timer_delete_locked(proc_t *p, timer_t tid, itimer_t *it) in timer_delete_locked() argument
109 ASSERT(!(it->it_lock & ITLK_REMOVE)); in timer_delete_locked()
110 ASSERT(it->it_lock & ITLK_LOCKED); in timer_delete_locked()
112 it->it_lock |= ITLK_REMOVE; in timer_delete_locked()
120 while (it->it_blockers) { in timer_delete_locked()
121 timer_unlock(p, it); in timer_delete_locked()
122 cv_wait(&it->it_cv, &p->p_lock); in timer_delete_locked()
123 timer_lock(p, it); in timer_delete_locked()
126 ASSERT(p->p_itimer[tid] == it); in timer_delete_locked()
138 it->it_backend->clk_timer_delete(it); in timer_delete_locked()
140 if (it->it_portev) { in timer_delete_locked()
141 mutex_enter(&it->it_mutex); in timer_delete_locked()
142 if (it->it_portev) { in timer_delete_locked()
145 (void) port_dissociate_ksource(it->it_portfd, in timer_delete_locked()
146 PORT_SOURCE_TIMER, (port_source_t *)it->it_portsrc); in timer_delete_locked()
147 pev = (port_kevent_t *)it->it_portev; in timer_delete_locked()
148 it->it_portev = NULL; in timer_delete_locked()
149 it->it_flags &= ~IT_PORT; in timer_delete_locked()
150 it->it_pending = 0; in timer_delete_locked()
151 mutex_exit(&it->it_mutex); in timer_delete_locked()
155 mutex_exit(&it->it_mutex); in timer_delete_locked()
167 if (it->it_pending > 0) { in timer_delete_locked()
168 it->it_sigq->sq_func = NULL; in timer_delete_locked()
170 kmem_free(it->it_sigq, sizeof (sigqueue_t)); in timer_delete_locked()
173 ASSERT(it->it_blockers == 0); in timer_delete_locked()
174 kmem_cache_free(clock_timer_cache, it); in timer_delete_locked()
202 itimer_t **itp, *it; in timer_grab() local
209 if ((itp = p->p_itimer) == NULL || (it = itp[tid]) == NULL) { in timer_grab()
214 timer_lock(p, it); in timer_grab()
216 if (it->it_lock & ITLK_REMOVE) { in timer_grab()
220 timer_unlock(p, it); in timer_grab()
227 return (it); in timer_grab()
236 timer_release(proc_t *p, itimer_t *it) in timer_release() argument
239 timer_unlock(p, it); in timer_release()
249 timer_delete_grabbed(proc_t *p, timer_t tid, itimer_t *it) in timer_delete_grabbed() argument
252 timer_delete_locked(p, tid, it); in timer_delete_grabbed()
383 itimer_t *it = (itimer_t *)sigq->sq_backptr; in timer_signal() local
391 mutex_enter(&it->it_mutex); in timer_signal()
392 ASSERT(it->it_pending > 0); in timer_signal()
393 it->it_overrun = it->it_pending - 1; in timer_signal()
394 it->it_pending = 0; in timer_signal()
395 mutex_exit(&it->it_mutex); in timer_signal()
402 timer_fire(itimer_t *it) in timer_fire() argument
407 if (it->it_flags & IT_SIGNAL) { in timer_fire()
415 p = it->it_proc; in timer_fire()
436 mutex_enter(&it->it_mutex); in timer_fire()
438 if (it->it_pending > 0) { in timer_fire()
439 if (it->it_pending < INT_MAX) in timer_fire()
440 it->it_pending++; in timer_fire()
441 mutex_exit(&it->it_mutex); in timer_fire()
443 if (it->it_flags & IT_PORT) { in timer_fire()
444 it->it_pending = 1; in timer_fire()
445 port_send_event((port_kevent_t *)it->it_portev); in timer_fire()
446 mutex_exit(&it->it_mutex); in timer_fire()
447 } else if (it->it_flags & IT_SIGNAL) { in timer_fire()
448 it->it_pending = 1; in timer_fire()
449 mutex_exit(&it->it_mutex); in timer_fire()
450 sigaddqa(p, NULL, it->it_sigq); in timer_fire()
452 mutex_exit(&it->it_mutex); in timer_fire()
466 itimer_t *it, **itp; in timer_create() local
544 it = kmem_cache_alloc(clock_timer_cache, KM_SLEEP); in timer_create()
545 bzero(it, sizeof (itimer_t)); in timer_create()
546 mutex_init(&it->it_mutex, NULL, MUTEX_DEFAULT, NULL); in timer_create()
579 kmem_cache_free(clock_timer_cache, it); in timer_create()
603 sigq->sq_backptr = it; in timer_create()
604 it->it_sigq = sigq; in timer_create()
605 it->it_backend = backend; in timer_create()
606 it->it_lock = ITLK_LOCKED; in timer_create()
607 itp[i] = it; in timer_create()
631 it->it_flags |= IT_PORT; in timer_create()
636 (port_source_t **)&it->it_portsrc, timer_close_port, in timer_create()
637 (void *)it, NULL); in timer_create()
641 kmem_cache_free(clock_timer_cache, it); in timer_create()
651 (port_source_t *)it->it_portsrc); in timer_create()
654 kmem_cache_free(clock_timer_cache, it); in timer_create()
661 timer_port_callback, it); in timer_create()
662 it->it_portev = pkevp; in timer_create()
663 it->it_portfd = port; in timer_create()
666 it->it_flags |= IT_SIGNAL; in timer_create()
675 if ((error = backend->clk_timer_create(it, &ev)) != 0) in timer_create()
678 it->it_lwp = ttolwp(curthread); in timer_create()
679 it->it_proc = p; in timer_create()
690 timer_release(p, it); in timer_create()
701 ASSERT(!(it->it_lock & ITLK_REMOVE)); in timer_create()
702 timer_delete_grabbed(p, i, it); in timer_create()
711 itimer_t *it; in timer_gettime() local
715 if ((it = timer_grab(p, tid)) == NULL) in timer_gettime()
718 error = it->it_backend->clk_timer_gettime(it, &when); in timer_gettime()
720 timer_release(p, it); in timer_gettime()
746 itimer_t *it; in timer_settime() local
773 if ((it = timer_grab(p, tid)) == NULL) in timer_settime()
776 error = it->it_backend->clk_timer_settime(it, flags, &when); in timer_settime()
778 timer_release(p, it); in timer_settime()
787 itimer_t *it; in timer_delete() local
789 if ((it = timer_grab(p, tid)) == NULL) in timer_delete()
792 timer_delete_grabbed(p, tid, it); in timer_delete()
802 itimer_t *it; in timer_getoverrun() local
804 if ((it = timer_grab(p, tid)) == NULL) in timer_getoverrun()
812 overrun = it->it_overrun; in timer_getoverrun()
815 timer_release(p, it); in timer_getoverrun()
829 itimer_t *it, **itp; in timer_lwpexit() local
837 if ((it = itp[i]) == NULL) in timer_lwpexit()
840 timer_lock(p, it); in timer_lwpexit()
842 if ((it->it_lock & ITLK_REMOVE) || it->it_lwp != lwp) { in timer_lwpexit()
847 timer_unlock(p, it); in timer_lwpexit()
858 it->it_lwp = NULL; in timer_lwpexit()
859 timer_unlock(p, it); in timer_lwpexit()
873 itimer_t *it, **itp; in timer_lwpbind() local
881 if ((it = itp[i]) == NULL) in timer_lwpbind()
884 timer_lock(p, it); in timer_lwpbind()
886 if (!(it->it_lock & ITLK_REMOVE) && it->it_lwp == lwp) { in timer_lwpbind()
891 it->it_backend->clk_timer_lwpbind(it); in timer_lwpbind()
895 timer_unlock(p, it); in timer_lwpbind()
928 itimer_t *it = arg; in timer_port_callback() local
930 mutex_enter(&it->it_mutex); in timer_port_callback()
931 if (curproc != it->it_proc) { in timer_port_callback()
933 mutex_exit(&it->it_mutex); in timer_port_callback()
936 *events = it->it_pending; /* 1 = 1 event, >1 # of overflows */ in timer_port_callback()
937 it->it_pending = 0; /* reinit overflow counter */ in timer_port_callback()
948 mutex_exit(&it->it_mutex); in timer_port_callback()
966 itimer_t *it; in timer_close_port() local
969 if ((it = timer_grab(p, tid)) == NULL) in timer_close_port()
971 if (it->it_portev) { in timer_close_port()
972 mutex_enter(&it->it_mutex); in timer_close_port()
973 if (it->it_portfd == port) { in timer_close_port()
975 pev = (port_kevent_t *)it->it_portev; in timer_close_port()
976 it->it_portev = NULL; in timer_close_port()
977 it->it_flags &= ~IT_PORT; in timer_close_port()
978 mutex_exit(&it->it_mutex); in timer_close_port()
982 mutex_exit(&it->it_mutex); in timer_close_port()
985 timer_release(p, it); in timer_close_port()