| 155 | }; |
| 156 | |
| 157 | void contention_worker(void* arg) { |
| 158 | auto* ctx = reinterpret_cast<ContentionArgs*>(arg); |
| 159 | for (int i = 0; i < 5; ++i) { |
| 160 | (void)ctx->mtx->Lock(); |
| 161 | int val = ctx->counter->load(); |
| 162 | (void)sys_sleep(10); |
| 163 | ctx->counter->store(val + 1); |
| 164 | (void)ctx->mtx->UnLock(); |
| 165 | } |
| 166 | sys_exit(0); |
| 167 | } |
| 168 | |
| 169 | void test_mutex_contention(void* /*arg*/) { |
| 170 | klog::Info("=== Mutex Contention Test ==="); |