fixup! WIP: rtkit support
This commit is contained in:
parent
06c56eb047
commit
7b77aebb19
|
@ -8,6 +8,7 @@ pkgs.mkShell {
|
||||||
# For documentation
|
# For documentation
|
||||||
doxygen
|
doxygen
|
||||||
python3Packages.sphinx
|
python3Packages.sphinx
|
||||||
|
python3Packages.sphinx-rtd-theme
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "lib/fmt/ExceptionFormatter.hxx"
|
#include "lib/fmt/ExceptionFormatter.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
#include <boost/stacktrace.hpp>
|
||||||
|
|
||||||
static constexpr Domain event_domain("event");
|
static constexpr Domain event_domain("event");
|
||||||
|
|
||||||
|
@ -47,7 +48,8 @@ EventThread::Run() noexcept
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
FmtInfo(event_domain,
|
FmtInfo(event_domain,
|
||||||
"RTIOThread could not get realtime scheduling, continuing anyway: {}",
|
"RTIOThread could not get realtime scheduling, continuing anyway: {}",
|
||||||
std::current_exception());
|
/* std::current_exception()); */
|
||||||
|
boost::stacktrace::to_string(boost::stacktrace::stacktrace()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#include <yajl_parse.h>
|
#include <yajl/yajl_parse.h>
|
||||||
|
|
||||||
namespace Yajl {
|
namespace Yajl {
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <yajl_gen.h>
|
#include <yajl/yajl_gen.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <span>
|
#include <span>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <yajl_parse.h>
|
#include <yajl/yajl_parse.h>
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include "lib/fmt/RuntimeError.hxx"
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -271,7 +272,7 @@ SetThreadRealtime()
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
struct sched_param sched_param;
|
struct sched_param sched_param;
|
||||||
sched_param.sched_priority = 40;
|
sched_param.sched_priority = 20;
|
||||||
|
|
||||||
int policy = SCHED_FIFO;
|
int policy = SCHED_FIFO;
|
||||||
#ifdef SCHED_RESET_ON_FORK
|
#ifdef SCHED_RESET_ON_FORK
|
||||||
|
@ -284,9 +285,13 @@ SetThreadRealtime()
|
||||||
DBusError error;
|
DBusError error;
|
||||||
DBusConnection *system_bus;
|
DBusConnection *system_bus;
|
||||||
|
|
||||||
if (!(system_bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) {
|
dbus_error_init(&error);
|
||||||
throw MakeErrno("could not connect to dbus");
|
|
||||||
}
|
system_bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
|
||||||
|
if (dbus_error_is_set(&error)) {
|
||||||
|
throw FmtRuntimeError("could not connect to dbus: %s", error.message);
|
||||||
|
}
|
||||||
|
dbus_error_free(&error);
|
||||||
|
|
||||||
int max_realtime_priority;
|
int max_realtime_priority;
|
||||||
if ((max_realtime_priority = rtkit_get_max_realtime_priority(system_bus)) < 0) {
|
if ((max_realtime_priority = rtkit_get_max_realtime_priority(system_bus)) < 0) {
|
||||||
|
@ -295,12 +300,12 @@ SetThreadRealtime()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max_realtime_priority < sched_param.sched_priority) {
|
if (max_realtime_priority < sched_param.sched_priority) {
|
||||||
dbus_connection_unref(system_bus);
|
sched_param.sched_priority = max_realtime_priority;
|
||||||
throw MakeErrno("maximum realtime priority is below 40");
|
/* dbus_connection_unref(system_bus); */
|
||||||
|
/* throw MakeErrno("maximum realtime priority is below 40"); */
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t pid = getpid();
|
if (rtkit_make_realtime(system_bus, 0, sched_param.sched_priority) < 0) {
|
||||||
if (rtkit_make_realtime(system_bus, pid, sched_param.sched_priority) < 0) {
|
|
||||||
dbus_connection_unref(system_bus);
|
dbus_connection_unref(system_bus);
|
||||||
throw MakeErrno("failed to request realtime scheduling");
|
throw MakeErrno("failed to request realtime scheduling");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue