add interface for scheduling priority

This commit is contained in:
Carl Pearson
2019-10-01 06:55:50 -05:00
parent 343b2b35ca
commit bbda6e1262
6 changed files with 65 additions and 1 deletions

View File

@@ -13,6 +13,8 @@
#include <sys/types.h>
#include <unistd.h>
#include <sys/personality.h>
#include <sys/time.h>
#include <sys/resource.h>
#include "perfect/result.hpp"
@@ -107,6 +109,17 @@ Result set_personality(const int persona) {
}
return Result::SUCCESS;
}
// give the calling process the highest priority
Result set_high_priority() {
if (setpriority(PRIO_PROCESS, 0, -20)) {
return from_errno(errno);
}
return Result::SUCCESS;
}
}
} // namespace perfect

View File

@@ -0,0 +1,15 @@
#pragma once
#ifdef __linux__
#include "detail/os/linux.hpp"
#else
#error "unsupported platform"
#endif
#include "init.hpp"
namespace perfect {
Result set_high_priority() {
return detail::set_high_priority();
}
}