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

Function test_ticketlock

dpdk/app/test/test_ticketlock.c:203–315  ·  view source on GitHub ↗

* Test rte_eal_get_lcore_state() in addition to ticketlocks * as we have "waiting" then "running" lcores. */

Source from the content-addressed store, hash-verified

201 * as we have "waiting" then "running" lcores.
202 */
203static int
204test_ticketlock(void)
205{
206 int ret = 0;
207 int i;
208
209 /* worker cores should be waiting: print it */
210 RTE_LCORE_FOREACH_WORKER(i) {
211 printf("lcore %d state: %d\n", i,
212 (int) rte_eal_get_lcore_state(i));
213 }
214
215 rte_ticketlock_init(&tl);
216 rte_ticketlock_init(&tl_try);
217 rte_ticketlock_recursive_init(&tlr);
218 RTE_LCORE_FOREACH_WORKER(i) {
219 rte_ticketlock_init(&tl_tab[i]);
220 }
221
222 rte_ticketlock_lock(&tl);
223
224 RTE_LCORE_FOREACH_WORKER(i) {
225 rte_ticketlock_lock(&tl_tab[i]);
226 rte_eal_remote_launch(test_ticketlock_per_core, NULL, i);
227 }
228
229 /* worker cores should be busy: print it */
230 RTE_LCORE_FOREACH_WORKER(i) {
231 printf("lcore %d state: %d\n", i,
232 (int) rte_eal_get_lcore_state(i));
233 }
234 rte_ticketlock_unlock(&tl);
235
236 RTE_LCORE_FOREACH_WORKER(i) {
237 rte_ticketlock_unlock(&tl_tab[i]);
238 rte_delay_ms(10);
239 }
240
241 rte_eal_mp_wait_lcore();
242
243 rte_ticketlock_recursive_lock(&tlr);
244
245 /*
246 * Try to acquire a lock that we already own
247 */
248 if (!rte_ticketlock_recursive_trylock(&tlr)) {
249 printf("rte_ticketlock_recursive_trylock failed on a lock that "
250 "we already own\n");
251 ret = -1;
252 } else
253 rte_ticketlock_recursive_unlock(&tlr);
254
255 RTE_LCORE_FOREACH_WORKER(i) {
256 rte_eal_remote_launch(test_ticketlock_recursive_per_core,
257 NULL, i);
258 }
259 rte_ticketlock_recursive_unlock(&tlr);
260 rte_eal_mp_wait_lcore();

Callers

nothing calls this directly

Calls 15

rte_eal_get_lcore_stateFunction · 0.85
rte_ticketlock_initFunction · 0.85
rte_ticketlock_lockFunction · 0.85
rte_eal_remote_launchFunction · 0.85
rte_ticketlock_unlockFunction · 0.85
rte_delay_msFunction · 0.85
rte_eal_mp_wait_lcoreFunction · 0.85
rte_ticketlock_trylockFunction · 0.85

Tested by

no test coverage detected