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 20:06:27 +0000 (20:06 +0000)
commitffee0ee8a102101ded1d3fa398f20c4215e0c441
tree72fa5d1c678c5c169d42c9f89d67b92b049bd871
parentf505a01c14c37972b220876e9f05ef9fa1f238ac
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
hci/src/hci_layer.cc