From d4f4ad90f9fe754bc098bbb392ba780e5a1bb0b3 Mon Sep 17 00:00:00 2001 From: Soby Mathew Date: Tue, 18 Nov 2014 10:45:04 +0000 Subject: [PATCH] Remove the wfe() for bounded wait in bakery_lock This patch is an optimization in the bakery_lock_get() function which removes the wfe() when waiting for other contenders to choose their ticket i.e when their `entering` flag is set. Since the time taken to execute bakery_get_ticket() by other contenders is bounded, this wait is a bounded time wait. Hence the removal of wfe() and the corresponding sev() and dsb() in bakery_get_ticket() may result in better time performance during lock acquisition. Change-Id: I141bb21294226b54cb6e89e7cac0175c553afd8d --- lib/locks/bakery/bakery_lock.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/locks/bakery/bakery_lock.c b/lib/locks/bakery/bakery_lock.c index 7e71dec0f..6bdc35a5e 100644 --- a/lib/locks/bakery/bakery_lock.c +++ b/lib/locks/bakery/bakery_lock.c @@ -107,8 +107,6 @@ static unsigned int bakery_get_ticket(bakery_lock_t *bakery, unsigned int me) ++my_ticket; bakery->number[me] = my_ticket; bakery->entering[me] = 0; - dsb(); - sev(); return my_ticket; } @@ -151,7 +149,7 @@ void bakery_lock_get(bakery_lock_t *bakery) /* Wait for the contender to get their ticket */ while (bakery->entering[they]) - wfe(); + ; /* * If the other party is a contender, they'll have non-zero