-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
thread: Support making threads real time scheduled
Real time scheduling is needed for better control of when we commit updates to the kernel, so add a property to MetaThread that, if the thread implementation uses a kernel thread and not a user thread, RTKit is asked to make the thread real time scheduled using the maximum priority allowed. Currently RTKit doesn't support the GetAll() D-Bus properties method, so some fall back code is added, as GDBusProxy depends on GetAll() working to make the cached properties up to date. Once heftig/rtkit#30 lands and becomes widely available in distributions, the work around can be dropped. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
- Loading branch information
Showing
4 changed files
with
314 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# This program is free software; you can redistribute it and/or modify it under | ||
# the terms of the GNU Lesser General Public License as published by the Free | ||
# Software Foundation; either version 3 of the License, or (at your option) any | ||
# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text | ||
# of the license. | ||
|
||
__author__ = 'Jonas Ådahl' | ||
__copyright__ = '(c) 2022 Red Hat Inc.' | ||
|
||
import dbus | ||
from dbusmock import MOCK_IFACE, mockobject | ||
|
||
BUS_NAME = 'org.freedesktop.RealtimeKit1' | ||
MAIN_OBJ = '/org/freedesktop/RealtimeKit1' | ||
MAIN_IFACE = 'org.freedesktop.RealtimeKit1' | ||
SYSTEM_BUS = True | ||
|
||
|
||
def load(mock, parameters): | ||
mock.AddProperty(MAIN_IFACE, 'RTTimeUSecMax', dbus.Int64(200000)) | ||
mock.AddProperty(MAIN_IFACE, 'MaxRealtimePriority', dbus.Int32(20)) | ||
mock.AddProperty(MAIN_IFACE, 'MinNiceLevel', dbus.Int32(-15)) | ||
mock.priorities = dict() | ||
|
||
@dbus.service.method(MAIN_IFACE, in_signature='tu') | ||
def MakeThreadRealtime(self, thread, priority): | ||
self.priorities[thread] = priority | ||
|
||
@dbus.service.method(MOCK_IFACE) | ||
def Reset(self): | ||
self.priorities = dict() | ||
|
||
@dbus.service.method(MOCK_IFACE, in_signature='t', out_signature='u') | ||
def GetThreadPriority(self, thread): | ||
if thread in self.priorities: | ||
return self.priorities[thread] | ||
else: | ||
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters