OSDN Git Service

Move hci_thread to a message loop and prevent thread from spinning
authorAjay Panicker <apanicke@google.com>
Fri, 28 Apr 2017 22:26:38 +0000 (15:26 -0700)
committerAjay Panicker <apanicke@google.com>
Fri, 5 May 2017 22:36:56 +0000 (22:36 +0000)
commit48294531bf6e5a5db94766ae52a83454154cb3a1
treef4c28a0f6b73daf974ba115efc11006fbcee8daf
parent103b2c44d3db6172a2dc9319e215eeece504316e
Move hci_thread to a message loop and prevent thread from spinning

Before this patch, if there was a message on the command queue and
there were no command credits, the thread reactor would spin trying
to process the message on the command queue and would continue until
a credit was received. This led to a bug where upon switching users,
hci_thread would spin and try to use 100% of the CPU. This is fixed
by moving over to a message loop and queue system. The message loop
processes all the messages. If there aren't enough command credits,
command messages are deferred to the command queue and popped off
whenever more credits are aquired. The deferred queue has priority
to credits over recently posted messages.

Bug: 37733903
Test: Swap users with the real time scheduling patch applied, and
      general Bluetooth usage.
      TestTracker: 86249
Change-Id: Ib775e47f6d4810d3d7d8af5b3ba84adc4ada3da5
(cherry picked from commit ffee0ee8a102101ded1d3fa398f20c4215e0c441)
hci/src/hci_layer.cc