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

Function timer_set_running_state

dpdk/lib/timer/rte_timer.c:271–304  ·  view source on GitHub ↗

* if timer is pending, mark timer as running */

Source from the content-addressed store, hash-verified

269 * if timer is pending, mark timer as running
270 */
271static int
272timer_set_running_state(struct rte_timer *tim)
273{
274 union rte_timer_status prev_status, status;
275 unsigned lcore_id = rte_lcore_id();
276 int success = 0;
277
278 /* wait that the timer is in correct status before update,
279 * and mark it as running */
280 prev_status.u32 = rte_atomic_load_explicit(&tim->status.u32, rte_memory_order_relaxed);
281
282 while (success == 0) {
283 /* timer is not pending anymore */
284 if (prev_status.state != RTE_TIMER_PENDING)
285 return -1;
286
287 /* we know that the timer will be pending at this point
288 * mark it atomically as being running
289 */
290 status.state = RTE_TIMER_RUNNING;
291 status.owner = (int16_t)lcore_id;
292 /* RUNNING states are acting as locked states. If the
293 * timer is in RUNNING state, the state cannot be changed
294 * by other threads. So, we should use ACQUIRE here.
295 */
296 success = rte_atomic_compare_exchange_strong_explicit(&tim->status.u32,
297 (uint32_t *)(uintptr_t)&prev_status.u32,
298 status.u32,
299 rte_memory_order_acquire,
300 rte_memory_order_relaxed);
301 }
302
303 return 0;
304}
305
306/*
307 * Return a skiplist level for a new entry.

Callers 2

__rte_timer_manageFunction · 0.85
rte_timer_alt_manageFunction · 0.85

Calls 1

rte_lcore_idFunction · 0.85

Tested by

no test coverage detected