| 33 | #define WRITER_INTERRUPT_TIME 1 /* us */ |
| 34 | |
| 35 | static int |
| 36 | writer_run(void *arg) |
| 37 | { |
| 38 | struct data *data = arg; |
| 39 | uint64_t deadline; |
| 40 | |
| 41 | deadline = rte_get_timer_cycles() + |
| 42 | WRITER_RUNTIME * rte_get_timer_hz(); |
| 43 | |
| 44 | while (rte_get_timer_cycles() < deadline) { |
| 45 | bool interrupted; |
| 46 | uint64_t new_value; |
| 47 | unsigned int delay; |
| 48 | |
| 49 | new_value = rte_rand(); |
| 50 | |
| 51 | interrupted = rte_rand_max(INTERRUPTED_WRITER_FREQUENCY) == 0; |
| 52 | |
| 53 | rte_seqlock_write_lock(&data->lock); |
| 54 | |
| 55 | data->c = new_value; |
| 56 | data->b = new_value; |
| 57 | |
| 58 | if (interrupted) |
| 59 | rte_delay_us_block(WRITER_INTERRUPT_TIME); |
| 60 | |
| 61 | data->a = new_value; |
| 62 | |
| 63 | rte_seqlock_write_unlock(&data->lock); |
| 64 | |
| 65 | delay = rte_rand_max(WRITER_MAX_DELAY); |
| 66 | |
| 67 | rte_delay_us_block(delay); |
| 68 | } |
| 69 | |
| 70 | return TEST_SUCCESS; |
| 71 | } |
| 72 | |
| 73 | #define INTERRUPTED_READER_FREQUENCY 1000 |
| 74 | #define READER_INTERRUPT_TIME 1000 /* us */ |
no test coverage detected