Use load-acquire semantics while waiting for td_lock to be released. The

store should have release semantics and will have due to the dsb above it
so add a comment to explain this. [1]

While here update the code to not reload the current thread, it's already
in a register, we just need to not trash it.

Suggested by:	kib [1]
Sponsored by:	ABT Systems Ltd
This commit is contained in:
Andrew Turner 2015-09-07 14:01:18 +00:00
parent 0941640f34
commit 0a21ab2c4b

View File

@ -160,17 +160,18 @@ ENTRY(cpu_switch)
dsb sy
isb
/* Release the old thread */
/*
* Release the old thread. This doesn't need to be a store-release
* as the above dsb instruction will provide release semantics.
*/
str x2, [x0, #TD_LOCK]
#if defined(SCHED_ULE) && defined(SMP)
/* Read the value in blocked_lock */
ldr x0, =_C_LABEL(blocked_lock)
ldr x1, [x0]
/* Load curthread */
ldr x2, [x18, #PC_CURTHREAD]
ldr x2, [x0]
1:
ldr x3, [x2, #TD_LOCK]
cmp x3, x1
ldar x3, [x1, #TD_LOCK]
cmp x3, x2
b.eq 1b
#endif