From ede69959e4db5e47c28034005db3f2b5c75e8a03 Mon Sep 17 00:00:00 2001 From: chenqiuhao Date: Fri, 26 Oct 2018 15:03:20 +0800 Subject: [PATCH] debug for compare exchange --- kernel/src/arch/riscv32/compiler_rt.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/src/arch/riscv32/compiler_rt.rs b/kernel/src/arch/riscv32/compiler_rt.rs index aaf9be0..63752c9 100644 --- a/kernel/src/arch/riscv32/compiler_rt.rs +++ b/kernel/src/arch/riscv32/compiler_rt.rs @@ -56,7 +56,13 @@ unsafe fn __atomic_compare_exchange(dst: *mut T, expected: *mut T, let flags = interrupt::disable_and_store(); let val = read(dst); let success = val == read(expected); - write(dst, if success {desired} else {val}); + if success { + write(dst, desired); + write(expected, val); + } else { + write(expected, val); + } + interrupt::restore(flags); success }