|
|
@ -6,6 +6,7 @@ import subprocess |
|
|
|
import multiprocessing |
|
|
|
import multiprocessing |
|
|
|
from cffi import FFI |
|
|
|
from cffi import FFI |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from common.android import ANDROID |
|
|
|
from common.common_pyx import sec_since_boot # pylint: disable=no-name-in-module, import-error |
|
|
|
from common.common_pyx import sec_since_boot # pylint: disable=no-name-in-module, import-error |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -20,11 +21,7 @@ ffi = FFI() |
|
|
|
ffi.cdef("long syscall(long number, ...);") |
|
|
|
ffi.cdef("long syscall(long number, ...);") |
|
|
|
libc = ffi.dlopen(None) |
|
|
|
libc = ffi.dlopen(None) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _get_tid(): |
|
|
|
def set_realtime_priority(level): |
|
|
|
|
|
|
|
if os.getuid() != 0: |
|
|
|
|
|
|
|
print("not setting priority, not root") |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
if platform.machine() == "x86_64": |
|
|
|
if platform.machine() == "x86_64": |
|
|
|
NR_gettid = 186 |
|
|
|
NR_gettid = 186 |
|
|
|
elif platform.machine() == "aarch64": |
|
|
|
elif platform.machine() == "aarch64": |
|
|
@ -32,8 +29,25 @@ def set_realtime_priority(level): |
|
|
|
else: |
|
|
|
else: |
|
|
|
raise NotImplementedError |
|
|
|
raise NotImplementedError |
|
|
|
|
|
|
|
|
|
|
|
tid = libc.syscall(NR_gettid) |
|
|
|
return libc.syscall(NR_gettid) |
|
|
|
return subprocess.call(['chrt', '-f', '-p', str(level), str(tid)]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_realtime_priority(level): |
|
|
|
|
|
|
|
if os.getuid() != 0: |
|
|
|
|
|
|
|
print("not setting priority, not root") |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return subprocess.call(['chrt', '-f', '-p', str(level), str(_get_tid())]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_core_affinity(core): |
|
|
|
|
|
|
|
if os.getuid() != 0: |
|
|
|
|
|
|
|
print("not setting affinity, not root") |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ANDROID: |
|
|
|
|
|
|
|
return subprocess.call(['taskset', '-p', str(core), str(_get_tid())]) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
return -1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Ratekeeper(): |
|
|
|
class Ratekeeper(): |
|
|
|