Files
sunnypilot/selfdrive/rtshield.py
Josh Smith 2cae3a3799 Add type hints, small cleanups (#21080)
* improve tools.lib.kbhit and tools.sim.lib.keyboard_ctrl

* unpack more efficiently

* minor improvements

* agnos.py match spec better

* manual_ctrl test missing queue arg

* fix incorrect type annotation

* queues are generic

* varname reuse resulting in incorrect type inference

* bytes().hex() rather than bytes.hex(bytes())

* a bit of type hinting stuff
old-commit-hash: 77321dbac4
2021-06-03 12:21:04 +02:00

22 lines
555 B
Python
Executable File

#!/usr/bin/env python3
import os
import time
from typing import NoReturn
from common.realtime import set_core_affinity, set_realtime_priority
# RT shield - ensure CPU 3 always remains available for RT processes
# runs as SCHED_FIFO with minimum priority to ensure kthreads don't
# get scheduled onto CPU 3, but it's always preemptible by realtime
# openpilot processes
def main() -> NoReturn:
set_core_affinity(int(os.getenv("CORE", "3")))
set_realtime_priority(1)
while True:
time.sleep(0.000001)
if __name__ == "__main__":
main()