diff options
| -rw-r--r-- | services/sensorservice/hidl/SensorManager.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/services/sensorservice/hidl/SensorManager.cpp b/services/sensorservice/hidl/SensorManager.cpp index 0743fc39d6..06ff95cdc8 100644 --- a/services/sensorservice/hidl/SensorManager.cpp +++ b/services/sensorservice/hidl/SensorManager.cpp @@ -22,12 +22,14 @@ #include "SensorManager.h" +#include <sched.h> + +#include <thread> + #include "EventQueue.h" #include "DirectReportChannel.h" #include "utils.h" -#include <thread> - namespace android { namespace frameworks { namespace sensorservice { @@ -131,6 +133,14 @@ sp<::android::Looper> SensorManager::getLooper() { std::condition_variable looperSet; std::thread{[&mutex = mLooperMutex, &looper = mLooper, &looperSet] { + + struct sched_param p = {0}; + p.sched_priority = 10; + if (sched_setscheduler(0 /* current thread*/, SCHED_FIFO, &p) != 0) { + LOG(WARNING) << "Could not use SCHED_FIFO for looper thread: " + << strerror(errno); + } + std::unique_lock<std::mutex> lock(mutex); looper = Looper::prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS /* opts */); lock.unlock(); |