Add support for min scheduling policy to node.
The binder driver has always supported setting a
min nice value for transactions. It looks like this
was always set to an out-of-range value (0x7f);
correct this to use a value of 0 by default (which
corresponds to nice 0).
Additionally, the new driver supports setting
a minimum scheduler *policy* as well, by reserving
2 bits for the scheduler policy in the flat_binder_object
structure. Add APIs to set this policy on a server object,
and set them properly when passing the object into
the driver.
Bug: 37293077
Test: verified /d/binder output
Change-Id: I1206320c37e89efd523e342b5d56179e403eac50
diff --git a/Binder.cpp b/Binder.cpp
index 94b2074..3cb36ce 100644
--- a/Binder.cpp
+++ b/Binder.cpp
@@ -22,6 +22,7 @@
#include <hwbinder/IInterface.h>
#include <hwbinder/Parcel.h>
+#include <sched.h>
#include <stdio.h>
namespace android {
@@ -66,10 +67,18 @@
// ---------------------------------------------------------------------------
-BHwBinder::BHwBinder() : mExtras(nullptr)
+BHwBinder::BHwBinder() : mSchedPolicy(SCHED_NORMAL), mSchedPriority(0), mExtras(nullptr)
{
}
+int BHwBinder::getMinSchedulingPolicy() {
+ return mSchedPolicy;
+}
+
+int BHwBinder::getMinSchedulingPriority() {
+ return mSchedPriority;
+}
+
status_t BHwBinder::transact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags, TransactCallback callback)
{