sdm: Set SDM_EventThread as RealTime task with lowest priority

SDM_EventThread is very sensitive to any delay introduced by Runnable
state because if the next complete_commit starts during it's Runnable
state, then the VSYNC registration gets pushed out to next HW Vsync
boundary. Set SDM_EventThread as RealTime task with lowest priority
to assign any idle CPU and to avoid pre-emption from other RT tasks.

CRs-Fixed: 2579461
Change-Id: I73feb6613ade240aac7406489b854356e07c6eec
diff --git a/sdm/libs/core/drm/hw_events_drm.cpp b/sdm/libs/core/drm/hw_events_drm.cpp
index 25bad21..16a7249 100644
--- a/sdm/libs/core/drm/hw_events_drm.cpp
+++ b/sdm/libs/core/drm/hw_events_drm.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
+* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -332,6 +332,11 @@
   prctl(PR_SET_NAME, event_thread_name_.c_str(), 0, 0, 0);
   setpriority(PRIO_PROCESS, 0, kThreadPriorityUrgent);
 
+  // Real Time task with lowest priority.
+  struct sched_param param = {0};
+  param.sched_priority = sched_get_priority_min(SCHED_FIFO);
+  sched_setscheduler(0, SCHED_FIFO, &param);
+
   while (!exit_threads_) {
     int error = Sys::poll_(poll_fds_.data(), UINT32(poll_fds_.size()), -1);
     if (error <= 0) {