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

Function reader_run

dpdk/app/test/test_seqlock.c:76–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74#define READER_INTERRUPT_TIME 1000 /* us */
75
76static int
77reader_run(void *arg)
78{
79 struct reader *r = arg;
80 int rc = TEST_SUCCESS;
81
82 while (__atomic_load_n(&r->stop, __ATOMIC_RELAXED) == 0 &&
83 rc == TEST_SUCCESS) {
84 struct data *data = r->data;
85 bool interrupted;
86 uint32_t sn;
87 uint64_t a;
88 uint64_t b;
89 uint64_t c;
90
91 interrupted = rte_rand_max(INTERRUPTED_READER_FREQUENCY) == 0;
92
93 do {
94 sn = rte_seqlock_read_begin(&data->lock);
95
96 a = data->a;
97 if (interrupted)
98 rte_delay_us_block(READER_INTERRUPT_TIME);
99 c = data->c;
100 b = data->b;
101
102 } while (rte_seqlock_read_retry(&data->lock, sn));
103
104 if (a != b || b != c) {
105 printf("Reader observed inconsistent data values "
106 "%" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
107 a, b, c);
108 rc = TEST_FAILED;
109 }
110 }
111
112 return rc;
113}
114
115static void
116reader_stop(struct reader *reader)

Callers

nothing calls this directly

Calls 5

rte_rand_maxFunction · 0.85
rte_seqlock_read_beginFunction · 0.85
rte_delay_us_blockFunction · 0.85
rte_seqlock_read_retryFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected