From f52a39cc4863b6f5cb47faf88cac2fe3a444debc Mon Sep 17 00:00:00 2001 From: Oliver Meier Date: Fri, 5 Dec 2014 17:51:09 +0100 Subject: [PATCH] [cm3/sync] mutex_lock now calls mutex_trylock repeatedly --- lib/cm3/sync.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/lib/cm3/sync.c b/lib/cm3/sync.c index a9f7c99a..41017257 100644 --- a/lib/cm3/sync.c +++ b/lib/cm3/sync.c @@ -45,20 +45,7 @@ uint32_t __strex(uint32_t val, volatile uint32_t *addr) void mutex_lock(mutex_t *m) { - uint32_t status = 0; - - do { - /* Wait until the mutex is unlocked. */ - while (__ldrex(m) != MUTEX_UNLOCKED); - - /* Try to acquire it. */ - status = __strex(MUTEX_LOCKED, m); - - /* Did we get it? If not then try again. */ - } while (status != 0); - - /* Execute the mysterious Data Memory Barrier instruction! */ - __dmb(); + while (!mutex_trylock(m)); } /* returns 1 if the lock was acquired */