mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-07-25 19:32:03 +08:00
ui: lower priority background threads (#38031)
* drop realtime so preempt can happen during swap * prime state and firehose * and params * above
This commit is contained in:
@@ -28,6 +28,11 @@ class Priority:
|
||||
CTRL_HIGH = 53
|
||||
|
||||
|
||||
def drop_realtime() -> None:
|
||||
if sys.platform == 'linux' and not PC:
|
||||
os.sched_setscheduler(0, os.SCHED_OTHER, os.sched_param(0))
|
||||
|
||||
|
||||
def set_core_affinity(cores: list[int]) -> None:
|
||||
if sys.platform == 'linux' and not PC:
|
||||
os.sched_setaffinity(0, cores)
|
||||
|
||||
@@ -6,6 +6,7 @@ import time
|
||||
|
||||
from openpilot.common.api import api_get
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.common.realtime import drop_realtime
|
||||
from openpilot.common.swaglog import cloudlog
|
||||
from openpilot.system.athena.registration import UNREGISTERED_DONGLE_ID
|
||||
from openpilot.selfdrive.ui.lib.api_helpers import get_token
|
||||
@@ -69,6 +70,7 @@ class PrimeState:
|
||||
cloudlog.info(f"Prime type updated to {prime_type}")
|
||||
|
||||
def _worker_thread(self) -> None:
|
||||
drop_realtime()
|
||||
from openpilot.selfdrive.ui.ui_state import ui_state, device
|
||||
while self._running:
|
||||
if not ui_state.started and device._awake:
|
||||
|
||||
@@ -5,6 +5,7 @@ import pyray as rl
|
||||
|
||||
from openpilot.common.api import api_get
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.common.realtime import drop_realtime
|
||||
from openpilot.common.swaglog import cloudlog
|
||||
from openpilot.selfdrive.ui.lib.api_helpers import get_token
|
||||
from openpilot.selfdrive.ui.ui_state import ui_state, device
|
||||
@@ -212,6 +213,7 @@ class FirehoseLayoutBase(Widget):
|
||||
cloudlog.error(f"Failed to fetch firehose stats: {e}")
|
||||
|
||||
def _update_loop(self):
|
||||
drop_realtime()
|
||||
while self._running:
|
||||
if not ui_state.started and device._awake:
|
||||
self._fetch_firehose_stats()
|
||||
|
||||
@@ -7,6 +7,7 @@ from enum import Enum
|
||||
from cereal import messaging, car, log
|
||||
from openpilot.common.filter_simple import FirstOrderFilter
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.common.realtime import drop_realtime
|
||||
from openpilot.common.swaglog import cloudlog
|
||||
from openpilot.selfdrive.ui.lib.prime_state import PrimeState
|
||||
from openpilot.system.ui.lib.application import gui_app
|
||||
@@ -122,6 +123,7 @@ class UIState:
|
||||
device.update()
|
||||
|
||||
def _params_refresh_worker(self):
|
||||
drop_realtime()
|
||||
while True:
|
||||
self.update_params()
|
||||
time.sleep(PARAM_UPDATE_TIME)
|
||||
@@ -256,6 +258,7 @@ class Device:
|
||||
self._brightness_thread.start()
|
||||
|
||||
def _brightness_worker(self):
|
||||
drop_realtime()
|
||||
while True:
|
||||
self._brightness_event.wait()
|
||||
self._brightness_event.clear()
|
||||
|
||||
Reference in New Issue
Block a user