Lines Matching refs:it

64 timer_lock(proc_t *p, itimer_t *it)  in timer_lock()  argument
68 while (it->it_lock & ITLK_LOCKED) { in timer_lock()
69 it->it_blockers++; in timer_lock()
70 cv_wait(&it->it_cv, &p->p_lock); in timer_lock()
71 it->it_blockers--; in timer_lock()
74 it->it_lock |= ITLK_LOCKED; in timer_lock()
83 timer_unlock(proc_t *p, itimer_t *it) in timer_unlock() argument
86 ASSERT(it->it_lock & ITLK_LOCKED); in timer_unlock()
87 it->it_lock &= ~ITLK_LOCKED; in timer_unlock()
88 cv_signal(&it->it_cv); in timer_unlock()
104 timer_delete_locked(proc_t *p, timer_t tid, itimer_t *it) in timer_delete_locked() argument
107 ASSERT(!(it->it_lock & ITLK_REMOVE)); in timer_delete_locked()
108 ASSERT(it->it_lock & ITLK_LOCKED); in timer_delete_locked()
110 it->it_lock |= ITLK_REMOVE; in timer_delete_locked()
118 while (it->it_blockers) { in timer_delete_locked()
119 timer_unlock(p, it); in timer_delete_locked()
120 cv_wait(&it->it_cv, &p->p_lock); in timer_delete_locked()
121 timer_lock(p, it); in timer_delete_locked()
124 ASSERT(p->p_itimer[tid] == it); in timer_delete_locked()
136 it->it_backend->clk_timer_delete(it); in timer_delete_locked()
138 if (it->it_portev) { in timer_delete_locked()
139 mutex_enter(&it->it_mutex); in timer_delete_locked()
140 if (it->it_portev) { in timer_delete_locked()
143 (void) port_dissociate_ksource(it->it_portfd, in timer_delete_locked()
144 PORT_SOURCE_TIMER, (port_source_t *)it->it_portsrc); in timer_delete_locked()
145 pev = (port_kevent_t *)it->it_portev; in timer_delete_locked()
146 it->it_portev = NULL; in timer_delete_locked()
147 it->it_flags &= ~IT_PORT; in timer_delete_locked()
148 it->it_pending = 0; in timer_delete_locked()
149 mutex_exit(&it->it_mutex); in timer_delete_locked()
153 mutex_exit(&it->it_mutex); in timer_delete_locked()
165 if (it->it_pending > 0) { in timer_delete_locked()
166 it->it_sigq->sq_func = NULL; in timer_delete_locked()
168 kmem_free(it->it_sigq, sizeof (sigqueue_t)); in timer_delete_locked()
171 ASSERT(it->it_blockers == 0); in timer_delete_locked()
172 kmem_cache_free(clock_timer_cache, it); in timer_delete_locked()
200 itimer_t **itp, *it; in timer_grab() local
207 if ((itp = p->p_itimer) == NULL || (it = itp[tid]) == NULL) { in timer_grab()
212 timer_lock(p, it); in timer_grab()
214 if (it->it_lock & ITLK_REMOVE) { in timer_grab()
218 timer_unlock(p, it); in timer_grab()
225 return (it); in timer_grab()
234 timer_release(proc_t *p, itimer_t *it) in timer_release() argument
237 timer_unlock(p, it); in timer_release()
247 timer_delete_grabbed(proc_t *p, timer_t tid, itimer_t *it) in timer_delete_grabbed() argument
250 timer_delete_locked(p, tid, it); in timer_delete_grabbed()
381 itimer_t *it = (itimer_t *)sigq->sq_backptr; in timer_signal() local
389 mutex_enter(&it->it_mutex); in timer_signal()
390 ASSERT(it->it_pending > 0); in timer_signal()
391 it->it_overrun = it->it_pending - 1; in timer_signal()
392 it->it_pending = 0; in timer_signal()
393 mutex_exit(&it->it_mutex); in timer_signal()
400 timer_fire(itimer_t *it) in timer_fire() argument
405 if (it->it_flags & IT_SIGNAL) { in timer_fire()
413 p = it->it_proc; in timer_fire()
434 mutex_enter(&it->it_mutex); in timer_fire()
436 if (it->it_pending > 0) { in timer_fire()
437 if (it->it_pending < INT_MAX) in timer_fire()
438 it->it_pending++; in timer_fire()
439 mutex_exit(&it->it_mutex); in timer_fire()
441 if (it->it_flags & IT_PORT) { in timer_fire()
442 it->it_pending = 1; in timer_fire()
443 port_send_event((port_kevent_t *)it->it_portev); in timer_fire()
444 mutex_exit(&it->it_mutex); in timer_fire()
445 } else if (it->it_flags & IT_SIGNAL) { in timer_fire()
446 it->it_pending = 1; in timer_fire()
447 mutex_exit(&it->it_mutex); in timer_fire()
448 sigaddqa(p, NULL, it->it_sigq); in timer_fire()
450 mutex_exit(&it->it_mutex); in timer_fire()
464 itimer_t *it, **itp; in timer_create() local
542 it = kmem_cache_alloc(clock_timer_cache, KM_SLEEP); in timer_create()
543 bzero(it, sizeof (itimer_t)); in timer_create()
544 mutex_init(&it->it_mutex, NULL, MUTEX_DEFAULT, NULL); in timer_create()
577 kmem_cache_free(clock_timer_cache, it); in timer_create()
601 sigq->sq_backptr = it; in timer_create()
602 it->it_sigq = sigq; in timer_create()
603 it->it_backend = backend; in timer_create()
604 it->it_lock = ITLK_LOCKED; in timer_create()
605 itp[i] = it; in timer_create()
629 it->it_flags |= IT_PORT; in timer_create()
634 (port_source_t **)&it->it_portsrc, timer_close_port, in timer_create()
635 (void *)it, NULL); in timer_create()
639 kmem_cache_free(clock_timer_cache, it); in timer_create()
649 (port_source_t *)it->it_portsrc); in timer_create()
652 kmem_cache_free(clock_timer_cache, it); in timer_create()
659 timer_port_callback, it); in timer_create()
660 it->it_portev = pkevp; in timer_create()
661 it->it_portfd = port; in timer_create()
664 it->it_flags |= IT_SIGNAL; in timer_create()
673 if ((error = backend->clk_timer_create(it, &ev)) != 0) in timer_create()
676 it->it_lwp = ttolwp(curthread); in timer_create()
677 it->it_proc = p; in timer_create()
688 timer_release(p, it); in timer_create()
699 ASSERT(!(it->it_lock & ITLK_REMOVE)); in timer_create()
700 timer_delete_grabbed(p, i, it); in timer_create()
709 itimer_t *it; in timer_gettime() local
713 if ((it = timer_grab(p, tid)) == NULL) in timer_gettime()
716 error = it->it_backend->clk_timer_gettime(it, &when); in timer_gettime()
718 timer_release(p, it); in timer_gettime()
745 itimer_t *it; in timer_settime() local
772 if ((it = timer_grab(p, tid)) == NULL) in timer_settime()
782 if (it->it_backend->clk_clock_getres(&res) == 0 && res.tv_nsec > 1) { in timer_settime()
794 error = it->it_backend->clk_timer_settime(it, flags, &when); in timer_settime()
796 timer_release(p, it); in timer_settime()
805 itimer_t *it; in timer_delete() local
807 if ((it = timer_grab(p, tid)) == NULL) in timer_delete()
810 timer_delete_grabbed(p, tid, it); in timer_delete()
820 itimer_t *it; in timer_getoverrun() local
822 if ((it = timer_grab(p, tid)) == NULL) in timer_getoverrun()
830 overrun = it->it_overrun; in timer_getoverrun()
833 timer_release(p, it); in timer_getoverrun()
847 itimer_t *it, **itp; in timer_lwpexit() local
855 if ((it = itp[i]) == NULL) in timer_lwpexit()
858 timer_lock(p, it); in timer_lwpexit()
860 if ((it->it_lock & ITLK_REMOVE) || it->it_lwp != lwp) { in timer_lwpexit()
865 timer_unlock(p, it); in timer_lwpexit()
876 it->it_lwp = NULL; in timer_lwpexit()
877 timer_unlock(p, it); in timer_lwpexit()
891 itimer_t *it, **itp; in timer_lwpbind() local
899 if ((it = itp[i]) == NULL) in timer_lwpbind()
902 timer_lock(p, it); in timer_lwpbind()
904 if (!(it->it_lock & ITLK_REMOVE) && it->it_lwp == lwp) { in timer_lwpbind()
909 it->it_backend->clk_timer_lwpbind(it); in timer_lwpbind()
913 timer_unlock(p, it); in timer_lwpbind()
946 itimer_t *it = arg; in timer_port_callback() local
948 mutex_enter(&it->it_mutex); in timer_port_callback()
949 if (curproc != it->it_proc) { in timer_port_callback()
951 mutex_exit(&it->it_mutex); in timer_port_callback()
954 *events = it->it_pending; /* 1 = 1 event, >1 # of overflows */ in timer_port_callback()
955 it->it_pending = 0; /* reinit overflow counter */ in timer_port_callback()
966 mutex_exit(&it->it_mutex); in timer_port_callback()
984 itimer_t *it; in timer_close_port() local
987 if ((it = timer_grab(p, tid)) == NULL) in timer_close_port()
989 if (it->it_portev) { in timer_close_port()
990 mutex_enter(&it->it_mutex); in timer_close_port()
991 if (it->it_portfd == port) { in timer_close_port()
993 pev = (port_kevent_t *)it->it_portev; in timer_close_port()
994 it->it_portev = NULL; in timer_close_port()
995 it->it_flags &= ~IT_PORT; in timer_close_port()
996 mutex_exit(&it->it_mutex); in timer_close_port()
1000 mutex_exit(&it->it_mutex); in timer_close_port()
1003 timer_release(p, it); in timer_close_port()