src/dpdk/lib/librte_timer/rte_timer.c
static int
timer_set_running_state(struct rte_timer *tim)
{
	union rte_timer_status prev_status, status;
	unsigned lcore_id = rte_lcore_id();
	int success = 0;

	/* wait that the timer is in correct status before update,
	 * and mark it as running */
	prev_status.u32 = __atomic_load_n(&tim->status.u32, __ATOMIC_RELAXED);

	while (success == 0) {
		/* timer is not pending anymore */
		if (prev_status.state != RTE_TIMER_PENDING)
			return -1;

		/* we know that the timer will be pending at this point
		 * mark it atomically as being running
		 */
		status.state = RTE_TIMER_RUNNING;
		status.owner = (int16_t)lcore_id;
		/* RUNNING states are acting as locked states. If the
		 * timer is in RUNNING state, the state cannot be changed
		 * by other threads. So, we should use ACQUIRE here.
		 */
		success = __atomic_compare_exchange_n(&tim->status.u32,
					      &prev_status.u32,
					      status.u32, 0,
					      __ATOMIC_ACQUIRE,
					      __ATOMIC_RELAXED);
	}

	return 0;
}
/*
 * if timer is pending, mark timer as running
 */
if timer is pending, mark timer as running
if timer is pending mark timer as running
static int
timer_set_running_state(struct rte_timer *tim)
{
	union rte_timer_status prev_status, status;
	unsigned lcore_id = rte_lcore_id();
	int success = 0;
	prev_status.u32 = __atomic_load_n(&tim->status.u32, __ATOMIC_RELAXED);
	while (success == 0) {
		if (prev_status.state != RTE_TIMER_PENDING)
			return -1;
		status.state = RTE_TIMER_RUNNING;
		status.owner = (int16_t)lcore_id;
		success = __atomic_compare_exchange_n(&tim->status.u32,
					      &prev_status.u32,
					      status.u32, 0,
					      __ATOMIC_ACQUIRE,
					      __ATOMIC_RELAXED);
	}
	return 0;
}
static int timer_set_running_state ( struct rte_timer * tim ) { union rte_timer_status prev_status , status ; unsigned lcore_id = rte_lcore_id ( ) ; int success = 0 ; prev_status . u32 = __atomic_load_n ( & tim -> status . u32 , __ATOMIC_RELAXED ) ; while ( success == 0 ) { if ( prev_status . state != RTE_TIMER_PENDING ) return -1 ; status . state = RTE_TIMER_RUNNING ; status . owner = ( int16_t ) lcore_id ; success = __atomic_compare_exchange_n ( & tim -> status . u32 , & prev_status . u32 , status . u32 , 0 , __ATOMIC_ACQUIRE , __ATOMIC_RELAXED ) ; } return 0 ; }
if timer is pending, mark timer as running
if timer is pending mark timer as running
/* wait that the timer is in correct status before update,
	 * and mark it as running */ /* timer is not pending anymore */ /* we know that the timer will be pending at this point
		 * mark it atomically as being running
		 */ /* RUNNING states are acting as locked states. If the
		 * timer is in RUNNING state, the state cannot be changed
		 * by other threads. So, we should use ACQUIRE here.
		 */