| 74 | #define READER_INTERRUPT_TIME 1000 /* us */ |
| 75 | |
| 76 | static int |
| 77 | reader_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 | |
| 115 | static void |
| 116 | reader_stop(struct reader *reader) |
nothing calls this directly
no test coverage detected