MCPcopy Create free account
hub / github.com/F-Stack/f-stack / timer_add

Function timer_add

dpdk/lib/timer/rte_timer.c:390–420  ·  view source on GitHub ↗

call with lock held as necessary * add in list * timer must be in config state * timer must not be in a list */

Source from the content-addressed store, hash-verified

388 * timer must not be in a list
389 */
390static void
391timer_add(struct rte_timer *tim, unsigned int tim_lcore,
392 struct priv_timer *priv_timer)
393{
394 unsigned lvl;
395 struct rte_timer *prev[MAX_SKIPLIST_DEPTH+1];
396
397 /* find where exactly this element goes in the list of elements
398 * for each depth. */
399 timer_get_prev_entries(tim->expire, tim_lcore, prev, priv_timer);
400
401 /* now assign it a new level and add at that level */
402 const unsigned tim_level = timer_get_skiplist_level(
403 priv_timer[tim_lcore].curr_skiplist_depth);
404 if (tim_level == priv_timer[tim_lcore].curr_skiplist_depth)
405 priv_timer[tim_lcore].curr_skiplist_depth++;
406
407 lvl = tim_level;
408 while (lvl > 0) {
409 tim->sl_next[lvl] = prev[lvl]->sl_next[lvl];
410 prev[lvl]->sl_next[lvl] = tim;
411 lvl--;
412 }
413 tim->sl_next[0] = prev[0]->sl_next[0];
414 prev[0]->sl_next[0] = tim;
415
416 /* save the lowest list entry into the expire field of the dummy hdr
417 * NOTE: this is not atomic on 32-bit*/
418 priv_timer[tim_lcore].pending_head.expire = priv_timer[tim_lcore].\
419 pending_head.sl_next[0]->expire;
420}
421
422/*
423 * del from list, lock if needed

Callers 1

__rte_timer_resetFunction · 0.85

Calls 2

timer_get_prev_entriesFunction · 0.85
timer_get_skiplist_levelFunction · 0.85

Tested by

no test coverage detected