From bf29ee2a49cfa6e87e535dcb1476ff1336f8bdf9 Mon Sep 17 00:00:00 2001 From: John Reck Date: Tue, 24 Mar 2015 12:31:44 -0700 Subject: [PATCH] Shave another 10us off of hwuitask pthread_cond_signal does not need the mutex to be held to signal. This results in the thread waking up trying to grab the lock, failing, the signaling thread to wake up, release the lock, immediately get preempted for the signaled thread which can now proceed. Release the mutex before signaling to avoid the ping-pong scheduling issue, which shaves another 10us off of this Change-Id: Ie6bccca031ba6528f357eae8352b74626a6318c7 --- libs/hwui/thread/Signal.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/hwui/thread/Signal.h b/libs/hwui/thread/Signal.h index dcf54498b9f5f..d4cfeeb29c173 100644 --- a/libs/hwui/thread/Signal.h +++ b/libs/hwui/thread/Signal.h @@ -30,8 +30,10 @@ public: ~Signal() { } void signal() { - Mutex::Autolock l(mLock); - mSignaled = true; + { + Mutex::Autolock l(mLock); + mSignaled = true; + } mCondition.signal(mType); }