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()
392 itimer_t *it = (itimer_t *)sigq->sq_backptr; in timer_signal() local
400 mutex_enter(&it->it_mutex); in timer_signal()
401 ASSERT(it->it_pending > 0); in timer_signal()
402 it->it_overrun = it->it_pending - 1; in timer_signal()
403 it->it_pending = 0; in timer_signal()
404 mutex_exit(&it->it_mutex); in timer_signal()
411 timer_fire(itimer_t *it) in timer_fire() argument
416 if (it->it_flags & IT_SIGNAL) { in timer_fire()
424 p = it->it_proc; in timer_fire()
445 mutex_enter(&it->it_mutex); in timer_fire()
447 if (it->it_pending > 0) { in timer_fire()
448 if (it->it_pending < INT_MAX) in timer_fire()
449 it->it_pending++; in timer_fire()
450 mutex_exit(&it->it_mutex); in timer_fire()
452 if (it->it_flags & IT_PORT) { in timer_fire()
453 it->it_pending = 1; in timer_fire()
454 port_send_event((port_kevent_t *)it->it_portev); in timer_fire()
455 mutex_exit(&it->it_mutex); in timer_fire()
456 } else if (it->it_flags & IT_SIGNAL) { in timer_fire()
457 it->it_pending = 1; in timer_fire()
458 mutex_exit(&it->it_mutex); in timer_fire()
459 sigaddqa(p, NULL, it->it_sigq); in timer_fire()
461 mutex_exit(&it->it_mutex); in timer_fire()
475 itimer_t *it, **itp; in timer_create() local
553 it = kmem_cache_alloc(clock_timer_cache, KM_SLEEP); in timer_create()
554 bzero(it, sizeof (itimer_t)); in timer_create()
555 mutex_init(&it->it_mutex, NULL, MUTEX_DEFAULT, NULL); in timer_create()
588 kmem_cache_free(clock_timer_cache, it); in timer_create()
612 sigq->sq_backptr = it; in timer_create()
613 it->it_sigq = sigq; in timer_create()
614 it->it_backend = backend; in timer_create()
615 it->it_lock = ITLK_LOCKED; in timer_create()
616 itp[i] = it; in timer_create()
640 it->it_flags |= IT_PORT; in timer_create()
645 (port_source_t **)&it->it_portsrc, timer_close_port, in timer_create()
646 (void *)it, NULL); in timer_create()
650 kmem_cache_free(clock_timer_cache, it); in timer_create()
660 (port_source_t *)it->it_portsrc); in timer_create()
663 kmem_cache_free(clock_timer_cache, it); in timer_create()
670 timer_port_callback, it); in timer_create()
671 it->it_portev = pkevp; in timer_create()
672 it->it_portfd = port; in timer_create()
675 it->it_flags |= IT_SIGNAL; in timer_create()
684 if ((error = backend->clk_timer_create(it, timer_fire)) != 0) in timer_create()
687 it->it_lwp = ttolwp(curthread); in timer_create()
688 it->it_proc = p; in timer_create()
699 timer_release(p, it); in timer_create()
710 ASSERT(!(it->it_lock & ITLK_REMOVE)); in timer_create()
711 timer_delete_grabbed(p, i, it); in timer_create()
720 itimer_t *it; in timer_gettime() local
724 if ((it = timer_grab(p, tid)) == NULL) in timer_gettime()
727 error = it->it_backend->clk_timer_gettime(it, &when); in timer_gettime()
729 timer_release(p, it); in timer_gettime()
755 itimer_t *it; in timer_settime() local
782 if ((it = timer_grab(p, tid)) == NULL) in timer_settime()
785 error = it->it_backend->clk_timer_settime(it, flags, &when); in timer_settime()
787 timer_release(p, it); in timer_settime()
796 itimer_t *it; in timer_delete() local
798 if ((it = timer_grab(p, tid)) == NULL) in timer_delete()
801 timer_delete_grabbed(p, tid, it); in timer_delete()
811 itimer_t *it; in timer_getoverrun() local
813 if ((it = timer_grab(p, tid)) == NULL) in timer_getoverrun()
821 overrun = it->it_overrun; in timer_getoverrun()
824 timer_release(p, it); in timer_getoverrun()
838 itimer_t *it, **itp; in timer_lwpexit() local
846 if ((it = itp[i]) == NULL) in timer_lwpexit()
849 timer_lock(p, it); in timer_lwpexit()
851 if ((it->it_lock & ITLK_REMOVE) || it->it_lwp != lwp) { in timer_lwpexit()
856 timer_unlock(p, it); in timer_lwpexit()
867 it->it_lwp = NULL; in timer_lwpexit()
868 timer_unlock(p, it); in timer_lwpexit()
882 itimer_t *it, **itp; in timer_lwpbind() local
890 if ((it = itp[i]) == NULL) in timer_lwpbind()
893 timer_lock(p, it); in timer_lwpbind()
895 if (!(it->it_lock & ITLK_REMOVE) && it->it_lwp == lwp) { in timer_lwpbind()
900 it->it_backend->clk_timer_lwpbind(it); in timer_lwpbind()
904 timer_unlock(p, it); in timer_lwpbind()
937 itimer_t *it = arg; in timer_port_callback() local
939 mutex_enter(&it->it_mutex); in timer_port_callback()
940 if (curproc != it->it_proc) { in timer_port_callback()
942 mutex_exit(&it->it_mutex); in timer_port_callback()
945 *events = it->it_pending; /* 1 = 1 event, >1 # of overflows */ in timer_port_callback()
946 it->it_pending = 0; /* reinit overflow counter */ in timer_port_callback()
957 mutex_exit(&it->it_mutex); in timer_port_callback()
975 itimer_t *it; in timer_close_port() local
978 if ((it = timer_grab(p, tid)) == NULL) in timer_close_port()
980 if (it->it_portev) { in timer_close_port()
981 mutex_enter(&it->it_mutex); in timer_close_port()
982 if (it->it_portfd == port) { in timer_close_port()
984 pev = (port_kevent_t *)it->it_portev; in timer_close_port()
985 it->it_portev = NULL; in timer_close_port()
986 it->it_flags &= ~IT_PORT; in timer_close_port()
987 mutex_exit(&it->it_mutex); in timer_close_port()
991 mutex_exit(&it->it_mutex); in timer_close_port()
994 timer_release(p, it); in timer_close_port()