Lines Matching +full:non +full:- +full:identical

4  * Copyright (c) 2003-2008 Fabrice Bellard
26 #include "qemu/main-loop.h"
29 #include "system/cpu-timers.h"
94 return timer_head && (timer_head->expire_time <= current_time); in timer_expired_ns()
105 qemu_event_init(&timer_list->timers_done_ev, true); in timerlist_new()
106 timer_list->clock = clock; in timerlist_new()
107 timer_list->notify_cb = cb; in timerlist_new()
108 timer_list->notify_opaque = opaque; in timerlist_new()
109 qemu_mutex_init(&timer_list->active_timers_lock); in timerlist_new()
110 QLIST_INSERT_HEAD(&clock->timerlists, timer_list, list); in timerlist_new()
117 if (timer_list->clock) { in timerlist_free()
120 qemu_mutex_destroy(&timer_list->active_timers_lock); in timerlist_free()
131 clock->type = type; in qemu_clock_init()
132 clock->enabled = (type == QEMU_CLOCK_VIRTUAL ? false : true); in qemu_clock_init()
133 QLIST_INIT(&clock->timerlists); in qemu_clock_init()
146 QLIST_FOREACH(timer_list, &clock->timerlists, list) { in qemu_clock_notify()
162 bool old = clock->enabled; in qemu_clock_enable()
163 clock->enabled = enabled; in qemu_clock_enable()
167 QLIST_FOREACH(tl, &clock->timerlists, list) { in qemu_clock_enable()
168 qemu_event_wait(&tl->timers_done_ev); in qemu_clock_enable()
175 return !!qatomic_read(&timer_list->active_timers); in timerlist_has_timers()
188 if (!qatomic_read(&timer_list->active_timers)) { in timerlist_expired()
192 WITH_QEMU_LOCK_GUARD(&timer_list->active_timers_lock) { in timerlist_expired()
193 if (!timer_list->active_timers) { in timerlist_expired()
196 expire_time = timer_list->active_timers->expire_time; in timerlist_expired()
199 return expire_time <= qemu_clock_get_ns(timer_list->clock->type); in timerlist_expired()
209 * As above, but return -1 for no deadline, and do not cap to 2^32
218 if (!qatomic_read(&timer_list->active_timers)) { in timerlist_deadline_ns()
219 return -1; in timerlist_deadline_ns()
222 if (!timer_list->clock->enabled) { in timerlist_deadline_ns()
223 return -1; in timerlist_deadline_ns()
227 * value but ->notify_cb() is called when the deadline changes. Therefore in timerlist_deadline_ns()
230 WITH_QEMU_LOCK_GUARD(&timer_list->active_timers_lock) { in timerlist_deadline_ns()
231 if (!timer_list->active_timers) { in timerlist_deadline_ns()
232 return -1; in timerlist_deadline_ns()
234 expire_time = timer_list->active_timers->expire_time; in timerlist_deadline_ns()
237 delta = expire_time - qemu_clock_get_ns(timer_list->clock->type); in timerlist_deadline_ns()
253 int64_t deadline = -1; in qemu_clock_deadline_ns_all()
260 if (!clock->enabled) { in qemu_clock_deadline_ns_all()
261 return -1; in qemu_clock_deadline_ns_all()
264 QLIST_FOREACH(timer_list, &clock->timerlists, list) { in qemu_clock_deadline_ns_all()
265 if (!qatomic_read(&timer_list->active_timers)) { in qemu_clock_deadline_ns_all()
268 qemu_mutex_lock(&timer_list->active_timers_lock); in qemu_clock_deadline_ns_all()
269 ts = timer_list->active_timers; in qemu_clock_deadline_ns_all()
271 while (ts && (ts->attributes & ~attr_mask)) { in qemu_clock_deadline_ns_all()
272 ts = ts->next; in qemu_clock_deadline_ns_all()
275 qemu_mutex_unlock(&timer_list->active_timers_lock); in qemu_clock_deadline_ns_all()
278 expire_time = ts->expire_time; in qemu_clock_deadline_ns_all()
279 qemu_mutex_unlock(&timer_list->active_timers_lock); in qemu_clock_deadline_ns_all()
281 delta = expire_time - qemu_clock_get_ns(type); in qemu_clock_deadline_ns_all()
292 if (timer_list->notify_cb) { in timerlist_notify()
293 timer_list->notify_cb(timer_list->notify_opaque, timer_list->clock->type); in timerlist_notify()
306 return -1; in qemu_timeout_ns_to_ms()
314 * little and effectively busy-wait in qemu_timeout_ns_to_ms()
324 * otherwise identical to g_poll
335 * seconds, which would turn a very long timeout into a busy-wait. in qemu_poll_ns()
358 ts->timer_list = timer_list_group->tl[type]; in timer_init_full()
359 ts->cb = cb; in timer_init_full()
360 ts->opaque = opaque; in timer_init_full()
361 ts->scale = scale; in timer_init_full()
362 ts->attributes = attributes; in timer_init_full()
363 ts->expire_time = -1; in timer_init_full()
368 assert(ts->expire_time == -1); in timer_deinit()
369 ts->timer_list = NULL; in timer_deinit()
376 ts->expire_time = -1; in timer_del_locked()
377 pt = &timer_list->active_timers; in timer_del_locked()
383 qatomic_set(pt, t->next); in timer_del_locked()
386 pt = &t->next; in timer_del_locked()
396 pt = &timer_list->active_timers; in timer_mod_ns_locked()
402 pt = &t->next; in timer_mod_ns_locked()
404 ts->expire_time = MAX(expire_time, 0); in timer_mod_ns_locked()
405 ts->next = *pt; in timer_mod_ns_locked()
408 return pt == &timer_list->active_timers; in timer_mod_ns_locked()
419 QEMUTimerList *timer_list = ts->timer_list; in timer_del()
422 qemu_mutex_lock(&timer_list->active_timers_lock); in timer_del()
424 qemu_mutex_unlock(&timer_list->active_timers_lock); in timer_del()
432 QEMUTimerList *timer_list = ts->timer_list; in timer_mod_ns()
435 qemu_mutex_lock(&timer_list->active_timers_lock); in timer_mod_ns()
438 qemu_mutex_unlock(&timer_list->active_timers_lock); in timer_mod_ns()
450 QEMUTimerList *timer_list = ts->timer_list; in timer_mod_anticipate_ns()
453 WITH_QEMU_LOCK_GUARD(&timer_list->active_timers_lock) { in timer_mod_anticipate_ns()
454 if (ts->expire_time == -1 || ts->expire_time > expire_time) { in timer_mod_anticipate_ns()
455 if (ts->expire_time != -1) { in timer_mod_anticipate_ns()
470 timer_mod_ns(ts, expire_time * ts->scale); in timer_mod()
475 timer_mod_anticipate_ns(ts, expire_time * ts->scale); in timer_mod_anticipate()
480 return ts->expire_time >= 0; in timer_pending()
485 return timer_expired_ns(timer_head, current_time * timer_head->scale); in timer_expired()
496 if (!qatomic_read(&timer_list->active_timers)) { in timerlist_run_timers()
500 qemu_event_reset(&timer_list->timers_done_ev); in timerlist_run_timers()
501 if (!timer_list->clock->enabled) { in timerlist_run_timers()
505 switch (timer_list->clock->type) { in timerlist_run_timers()
527 * checkpoint must be recorded/replayed before processing any non-EXTERNAL timer, in timerlist_run_timers()
529 * non-EXTERNAL timers may appear in the timers list while it being processed, in timerlist_run_timers()
533 current_time = qemu_clock_get_ns(timer_list->clock->type); in timerlist_run_timers()
534 qemu_mutex_lock(&timer_list->active_timers_lock); in timerlist_run_timers()
535 while ((ts = timer_list->active_timers)) { in timerlist_run_timers()
543 * it's being triggered with only non-EXTERNAL timers, because in timerlist_run_timers()
547 && timer_list->clock->type == QEMU_CLOCK_VIRTUAL in timerlist_run_timers()
548 && !(ts->attributes & QEMU_TIMER_ATTR_EXTERNAL) in timerlist_run_timers()
550 qemu_mutex_unlock(&timer_list->active_timers_lock); in timerlist_run_timers()
555 timer_list->active_timers = ts->next; in timerlist_run_timers()
556 ts->next = NULL; in timerlist_run_timers()
557 ts->expire_time = -1; in timerlist_run_timers()
558 cb = ts->cb; in timerlist_run_timers()
559 opaque = ts->opaque; in timerlist_run_timers()
562 qemu_mutex_unlock(&timer_list->active_timers_lock); in timerlist_run_timers()
564 qemu_mutex_lock(&timer_list->active_timers_lock); in timerlist_run_timers()
568 qemu_mutex_unlock(&timer_list->active_timers_lock); in timerlist_run_timers()
571 qemu_event_set(&timer_list->timers_done_ev); in timerlist_run_timers()
585 tlg->tl[type] = timerlist_new(type, cb, opaque); in timerlistgroup_init()
593 timerlist_free(tlg->tl[type]); in timerlistgroup_deinit()
602 progress |= timerlist_run_timers(tlg->tl[type]); in timerlistgroup_run_timers()
609 int64_t deadline = -1; in timerlistgroup_deadline_ns()
614 timerlist_deadline_ns(tlg->tl[type])); in timerlistgroup_deadline_ns()
654 return timer_pending(ts) ? ts->expire_time : -1; in timer_expire_time_ns()
679 int64_t warp = qemu_soonest_timeout(dest - clock, deadline); in qemu_clock_advance_virtual_time()
684 timerlist_run_timers(aio_context->tlg.tl[QEMU_CLOCK_VIRTUAL]); in qemu_clock_advance_virtual_time()