summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2012-03-14 20:58:52 +0000
committerVincent Palatin <vpalatin@chromium.org>2012-03-14 20:58:52 +0000
commitce60b937cb172690222b19026212718aac6fd469 (patch)
tree5ea5c163fab135725cd140520395a64353e0acdc
parent1a3becdbc2b99e9b215d8b21dba95f85b1469def (diff)
downloadchrome-ec-ce60b937cb172690222b19026212718aac6fd469.tar.gz
mutex: retry immediatly if we could not get exclusive access
When updating the lock field of the mutex to acquire it, if the store exclusive fails, we want to retry immediatly else if the failure has been triggered by the other user doing the mutex_unlock we might not be woken up. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=chrome-os-partner:8492 TEST=run on proto-0.5 and see that the temperature sensor and battery tasks are longer hanging (see the bug for details how to check it) Change-Id: I0c8a4e997666a7781b3837f0dbbc47ffbc06b6c3
-rw-r--r--core/cortex-m/task.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/core/cortex-m/task.c b/core/cortex-m/task.c
index aed0a6b13c..4e4928929e 100644
--- a/core/cortex-m/task.c
+++ b/core/cortex-m/task.c
@@ -339,8 +339,11 @@ void mutex_lock(struct mutex *mtx)
" it eq\n"
" strexeq %0, %2, [%1]\n"
: "=&r" (value)
- : "r" (&mtx->lock), "r" (1) : "cc");
- if (value) {
+ : "r" (&mtx->lock), "r" (2) : "cc");
+ /* "value" is equals to 1 if the store conditional failed,
+ * 2 if somebody else owns the mutex, 0 else.
+ */
+ if (value == 2) {
/* contention on the mutex */
task_wait_msg(0);
}