regressions/spinlock: Do not rely on RMW for counter update.

This makes it more likely to trigger load-store/store-load re-ordering
across critical sections.
ck_pring
Samy Al Bahra 10 years ago
parent 060ef37e5e
commit 7ffe069973

@ -87,16 +87,16 @@ thread(void *null CK_CC_UNUSED)
ck_error("is_locked operation failed."); ck_error("is_locked operation failed.");
#endif #endif
ck_pr_inc_uint(&locked); ck_pr_store_uint(&locked, locked + 1);
ck_pr_inc_uint(&locked); ck_pr_store_uint(&locked, locked + 1);
ck_pr_inc_uint(&locked); ck_pr_store_uint(&locked, locked + 1);
ck_pr_inc_uint(&locked); ck_pr_store_uint(&locked, locked + 1);
ck_pr_inc_uint(&locked); ck_pr_store_uint(&locked, locked + 1);
ck_pr_inc_uint(&locked); ck_pr_store_uint(&locked, locked + 1);
ck_pr_inc_uint(&locked); ck_pr_store_uint(&locked, locked + 1);
ck_pr_inc_uint(&locked); ck_pr_store_uint(&locked, locked + 1);
ck_pr_inc_uint(&locked); ck_pr_store_uint(&locked, locked + 1);
ck_pr_inc_uint(&locked); ck_pr_store_uint(&locked, locked + 1);
j = ck_pr_load_uint(&locked); j = ck_pr_load_uint(&locked);
@ -105,19 +105,18 @@ thread(void *null CK_CC_UNUSED)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
ck_pr_dec_uint(&locked); ck_pr_store_uint(&locked, locked - 1);
ck_pr_dec_uint(&locked); ck_pr_store_uint(&locked, locked - 1);
ck_pr_dec_uint(&locked); ck_pr_store_uint(&locked, locked - 1);
ck_pr_dec_uint(&locked); ck_pr_store_uint(&locked, locked - 1);
ck_pr_dec_uint(&locked); ck_pr_store_uint(&locked, locked - 1);
ck_pr_dec_uint(&locked); ck_pr_store_uint(&locked, locked - 1);
ck_pr_dec_uint(&locked); ck_pr_store_uint(&locked, locked - 1);
ck_pr_dec_uint(&locked); ck_pr_store_uint(&locked, locked - 1);
ck_pr_dec_uint(&locked); ck_pr_store_uint(&locked, locked - 1);
ck_pr_dec_uint(&locked); ck_pr_store_uint(&locked, locked - 1);
UNLOCK; UNLOCK;
LOCK; LOCK;
j = ck_pr_load_uint(&locked); j = ck_pr_load_uint(&locked);

Loading…
Cancel
Save