Lines Matching full:it

52  * may _only_ be tuned in /etc/system or by patching the kernel binary; it
58 * timer_lock() locks the specified interval timer. It doesn't look at the
59 * ITLK_REMOVE bit; it's up to callers to look at this if they need to
60 * care. p_lock must be held on entry; it may be dropped and reaquired,
63 * Note that timer_create() doesn't call timer_lock(); it creates timers
67 timer_lock(proc_t *p, itimer_t *it) in timer_lock() argument
71 while (it->it_lock & ITLK_LOCKED) { in timer_lock()
72 it->it_blockers++; in timer_lock()
73 cv_wait(&it->it_cv, &p->p_lock); in timer_lock()
74 it->it_blockers--; in timer_lock()
77 it->it_lock |= ITLK_LOCKED; in timer_lock()
82 * waiters. p_lock must be held on entry; it will not be dropped by
86 timer_unlock(proc_t *p, itimer_t *it) in timer_unlock() argument
89 ASSERT(it->it_lock & ITLK_LOCKED); in timer_unlock()
90 it->it_lock &= ~ITLK_LOCKED; in timer_unlock()
91 cv_signal(&it->it_cv); in timer_unlock()
96 * timer, and deletes the specified timer. It must be called with p_lock
100 * blockers have seen the ITLK_REMOVE and cleared out. It will then zero
107 timer_delete_locked(proc_t *p, timer_t tid, itimer_t *it) in timer_delete_locked() argument
110 ASSERT(!(it->it_lock & ITLK_REMOVE)); in timer_delete_locked()
111 ASSERT(it->it_lock & ITLK_LOCKED); in timer_delete_locked()
113 it->it_lock |= ITLK_REMOVE; in timer_delete_locked()
121 while (it->it_blockers) { in timer_delete_locked()
122 timer_unlock(p, it); in timer_delete_locked()
123 cv_wait(&it->it_cv, &p->p_lock); in timer_delete_locked()
124 timer_lock(p, it); in timer_delete_locked()
128 ASSERT(p->p_itimer[tid] == it); in timer_delete_locked()
133 * p_itimer[tid] to be NULL; no one can find it). Now we call into in timer_delete_locked()
134 * the clock backend to delete the timer; it is up to the backend to in timer_delete_locked()
140 it->it_backend->clk_timer_delete(it); in timer_delete_locked()
142 if (it->it_portev) { in timer_delete_locked()
143 mutex_enter(&it->it_mutex); in timer_delete_locked()
144 if (it->it_portev) { in timer_delete_locked()
147 (void) port_dissociate_ksource(it->it_portfd, in timer_delete_locked()
148 PORT_SOURCE_TIMER, (port_source_t *)it->it_portsrc); in timer_delete_locked()
149 pev = (port_kevent_t *)it->it_portev; in timer_delete_locked()
150 it->it_portev = NULL; in timer_delete_locked()
151 it->it_flags &= ~IT_PORT; in timer_delete_locked()
152 it->it_pending = 0; in timer_delete_locked()
153 mutex_exit(&it->it_mutex); in timer_delete_locked()
157 mutex_exit(&it->it_mutex); in timer_delete_locked()
169 if (it->it_pending > 0) { in timer_delete_locked()
170 it->it_sigq->sq_func = NULL; in timer_delete_locked()
172 kmem_free(it->it_sigq, sizeof (sigqueue_t)); in timer_delete_locked()
175 ASSERT(it->it_blockers == 0); in timer_delete_locked()
176 kmem_cache_free(clock_timer_cache, it); in timer_delete_locked()
190 * If timer_grab() fails, it will return NULL. timer_grab() will fail if
204 itimer_t **itp, *it; in timer_grab() local
213 (it = itp[tid]) == NULL) { in timer_grab()
218 timer_lock(p, it); in timer_grab()
220 if (it->it_lock & ITLK_REMOVE) { in timer_grab()
222 * Someone is removing this timer; it will soon be invalid. in timer_grab()
224 timer_unlock(p, it); in timer_grab()
231 return (it); in timer_grab()
237 * will drop it before returning.
240 timer_release(proc_t *p, itimer_t *it) in timer_release() argument
243 timer_unlock(p, it); in timer_release()
250 * p_lock, but will drop it before returning.
253 timer_delete_grabbed(proc_t *p, timer_t tid, itimer_t *it) in timer_delete_grabbed() argument
256 timer_delete_locked(p, tid, it); in timer_delete_grabbed()
403 itimer_t *it = (itimer_t *)sigq->sq_backptr; in timer_signal() local
411 mutex_enter(&it->it_mutex); in timer_signal()
412 ASSERT(it->it_pending > 0); in timer_signal()
413 it->it_overrun = it->it_pending - 1; in timer_signal()
414 it->it_pending = 0; in timer_signal()
415 mutex_exit(&it->it_mutex); in timer_signal()
422 timer_fire(itimer_t *it) in timer_fire() argument
427 if (it->it_flags & IT_SIGNAL) { in timer_fire()
429 * See the comment in timer_signal() for why it is not in timer_fire()
435 p = it->it_proc; in timer_fire()
446 * We don't need to use the p_lock because it is only in timer_fire()
456 mutex_enter(&it->it_mutex); in timer_fire()
458 if (it->it_pending > 0) { in timer_fire()
459 if (it->it_pending < INT_MAX) in timer_fire()
460 it->it_pending++; in timer_fire()
461 mutex_exit(&it->it_mutex); in timer_fire()
463 if (it->it_flags & IT_PORT) { in timer_fire()
464 it->it_pending = 1; in timer_fire()
465 port_send_event((port_kevent_t *)it->it_portev); in timer_fire()
466 mutex_exit(&it->it_mutex); in timer_fire()
467 } else if (it->it_flags & IT_SIGNAL) { in timer_fire()
468 it->it_pending = 1; in timer_fire()
469 mutex_exit(&it->it_mutex); in timer_fire()
470 sigaddqa(p, NULL, it->it_sigq); in timer_fire()
472 mutex_exit(&it->it_mutex); in timer_fire()
513 * Since we just allocated it, we know slot 0 is in timer_get_id()
566 * It's possible that other lower-indexed timers were freed while in timer_get_id()
589 itimer_t *it; in timer_create() local
665 * If we can't find an empty slot, we'll free it before returning. in timer_create()
670 * Allocate a timer and choose a slot for it. in timer_create()
672 it = kmem_cache_alloc(clock_timer_cache, KM_SLEEP); in timer_create()
673 bzero(it, sizeof (*it)); in timer_create()
674 mutex_init(&it->it_mutex, NULL, MUTEX_DEFAULT, NULL); in timer_create()
679 kmem_cache_free(clock_timer_cache, it); in timer_create()
702 sigq->sq_backptr = it; in timer_create()
703 it->it_sigq = sigq; in timer_create()
704 it->it_backend = backend; in timer_create()
705 it->it_lock = ITLK_LOCKED; in timer_create()
714 * - allocate a port event structure and prepare it to be sent in timer_create()
728 it->it_flags |= IT_PORT; in timer_create()
733 (port_source_t **)&it->it_portsrc, timer_close_port, in timer_create()
734 (void *)it, NULL); in timer_create()
737 kmem_cache_free(clock_timer_cache, it); in timer_create()
747 (port_source_t *)it->it_portsrc); in timer_create()
749 kmem_cache_free(clock_timer_cache, it); in timer_create()
756 timer_port_callback, it); in timer_create()
757 it->it_portev = pkevp; in timer_create()
758 it->it_portfd = port; in timer_create()
761 it->it_flags |= IT_SIGNAL; in timer_create()
765 p->p_itimer[i] = it; in timer_create()
772 if ((error = backend->clk_timer_create(it, timer_fire)) != 0) in timer_create()
775 it->it_lwp = ttolwp(curthread); in timer_create()
776 it->it_proc = p; in timer_create()
787 timer_release(p, it); in timer_create()
795 * Since we never unlocked the timer (it was born locked), it's in timer_create()
798 ASSERT(!(it->it_lock & ITLK_REMOVE)); in timer_create()
799 timer_delete_grabbed(p, i, it); in timer_create()
808 itimer_t *it; in timer_gettime() local
812 if ((it = timer_grab(p, tid)) == NULL) in timer_gettime()
815 error = it->it_backend->clk_timer_gettime(it, &when); in timer_gettime()
817 timer_release(p, it); in timer_gettime()
843 itimer_t *it; in timer_settime() local
870 if ((it = timer_grab(p, tid)) == NULL) in timer_settime()
873 error = it->it_backend->clk_timer_settime(it, flags, &when); in timer_settime()
875 timer_release(p, it); in timer_settime()
884 itimer_t *it; in timer_delete() local
886 if ((it = timer_grab(p, tid)) == NULL) in timer_delete()
889 timer_delete_grabbed(p, tid, it); in timer_delete()
899 itimer_t *it; in timer_getoverrun() local
901 if ((it = timer_grab(p, tid)) == NULL) in timer_getoverrun()
906 * it before looking at the value. in timer_getoverrun()
909 overrun = it->it_overrun; in timer_getoverrun()
912 timer_release(p, it); in timer_getoverrun()
926 itimer_t *it, **itp; in timer_lwpexit() local
934 if ((it = itp[i]) == NULL) in timer_lwpexit()
937 timer_lock(p, it); in timer_lwpexit()
939 if ((it->it_lock & ITLK_REMOVE) || it->it_lwp != lwp) { in timer_lwpexit()
941 * This timer is either being removed or it isn't in timer_lwpexit()
944 timer_unlock(p, it); in timer_lwpexit()
955 it->it_lwp = NULL; in timer_lwpexit()
956 timer_unlock(p, it); in timer_lwpexit()
970 itimer_t *it, **itp; in timer_lwpbind() local
978 if ((it = itp[i]) == NULL) in timer_lwpbind()
981 timer_lock(p, it); in timer_lwpbind()
983 if (!(it->it_lock & ITLK_REMOVE) && it->it_lwp == lwp) { in timer_lwpbind()
988 it->it_backend->clk_timer_lwpbind(it); in timer_lwpbind()
992 timer_unlock(p, it); in timer_lwpbind()
1028 itimer_t *it = arg; in timer_port_callback() local
1030 mutex_enter(&it->it_mutex); in timer_port_callback()
1031 if (curproc != it->it_proc) { in timer_port_callback()
1033 mutex_exit(&it->it_mutex); in timer_port_callback()
1036 *events = it->it_pending; /* 1 = 1 event, >1 # of overflows */ in timer_port_callback()
1037 it->it_pending = 0; /* reinit overflow counter */ in timer_port_callback()
1048 mutex_exit(&it->it_mutex); in timer_port_callback()
1055 * the port and it is not useable in this case.
1066 itimer_t *it; in timer_close_port() local
1069 if ((it = timer_grab(p, tid)) == NULL) in timer_close_port()
1071 if (it->it_portev) { in timer_close_port()
1072 mutex_enter(&it->it_mutex); in timer_close_port()
1073 if (it->it_portfd == port) { in timer_close_port()
1075 pev = (port_kevent_t *)it->it_portev; in timer_close_port()
1076 it->it_portev = NULL; in timer_close_port()
1077 it->it_flags &= ~IT_PORT; in timer_close_port()
1078 mutex_exit(&it->it_mutex); in timer_close_port()
1082 mutex_exit(&it->it_mutex); in timer_close_port()
1085 timer_release(p, it); in timer_close_port()