MCPcopy Create free account
hub / github.com/coreboot/coreboot / timer_queue_insert

Function timer_queue_insert

src/lib/timer_queue.c:38–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38static int timer_queue_insert(struct timer_queue *tq,
39 struct timeout_callback *tocb)
40{
41 int index;
42
43 /* No more slots. */
44 if (timer_queue_full(tq))
45 return -1;
46
47 index = tq->num_entries;
48 tq->num_entries++;
49 tq->queue[index] = tocb;
50
51 while (index != 0) {
52 struct timeout_callback *parent;
53 int parent_index;
54
55 parent_index = (index - 1) / 2;
56 parent = tq->queue[parent_index];
57
58 /* All other ancestors are less than or equal to the current. */
59 if (mono_time_cmp(&parent->expiration, &tocb->expiration) <= 0)
60 break;
61
62 /* The parent is greater than current. Swap them. */
63 tq->queue[parent_index] = tocb;
64 tq->queue[index] = parent;
65
66 index = parent_index;
67 }
68
69 return 0;
70}
71
72/* Get the index containing the entry with smallest value. */
73static int timer_queue_min_child_index(struct timer_queue *tq, int index)

Callers 1

timer_sched_callbackFunction · 0.85

Calls 2

timer_queue_fullFunction · 0.85
mono_time_cmpFunction · 0.85

Tested by

no test coverage detected