Android O MR1 IOT Release Smart Display r40.1J (OIMK.211005.001)
Change priority of thread allocation.
Now, threads are given the following priority:
a). the joining thread
b). the 'spawn thread on start thread'
c). kernel spawned threads
This reworks thread pool configuration to change two details:
- allows forcing 0 threads in a threadpool (if this is ever needed
- fixes issue where no threads can be used after configureRpcThreadpool
is called but before joinRpcThreadpool is called.
(a) automatically gives us a thread, so that must contribute to the
thread count. If the threadpool is of size >= 1, then (b) can also
contribute to the threadcount. Before, we only spawned (b) if not
willJoin. However, this causes a problem where you can't use HIDL
services after you call configureRpcThreadpool and before you call
joinRpcThreadpool because you need the (a) thread to join before it can
be used by the kernel to start more threads. Now, when maxThreads is
greater or equal to 2, we go ahead and spawn a thread on threadpool
start here. The upside of this is that you can use HIDL services at
this time. However, the downside is that two threads will be spawned
by default rather than one.
In the future, we could fix this downside by changing joinRpcThreadpool
to join (wait instead of becoming part of the threadpool) and always
send maxThreads - mSpawnThreadOnStart to the kernel. However, this
would mean that multiple threads calling joinRpcThreadpool would not
contribute any thread count (possibly breaking), and it means those
extra threads are incurring a cost without being able to do any work.
Test: hidl_test, boot, use service after configureRpcThreadpool and
1 file changed