Skip to content

Commit

Permalink
reduce max realtime priority to 90 instead of 99 ;)
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Feb 19, 2024
1 parent 3c13d70 commit de646b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions executables/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ int main(int argc, char *const *argv) {
int opt;
Options options{};
print_optimization_method();
SchedulingHelper::set_thread_params_max_realtime();
SchedulingHelper::print_current_thread_priority("TEST_MAIN");
SchedulingHelper::set_thread_params_max_realtime("TEST_MAIN");

while ((opt = getopt(argc, argv, "s:k:p:x:t:")) != -1) {
switch (opt) {
Expand Down
8 changes: 6 additions & 2 deletions wifibroadcast/HelperSources/SchedulingHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ static void print_current_thread_priority(const std::string& name) {
}

// this thread should run as close to realtime as possible
static void set_thread_params_max_realtime(const std::string& tag="") {
// https://youtu.be/NrjXEaTSyrw?t=647
// COMMENT: Please don't ever use 99 for your application, there are some kernel threads that run at 99 that are really important
// So ... lets use 90 for now
static void set_thread_params_max_realtime(const std::string& tag,const int priority=90) {
pthread_t target=pthread_self();
int policy = SCHED_FIFO;
sched_param param{};
param.sched_priority = sched_get_priority_max(policy);
//param.sched_priority = sched_get_priority_max(policy);
param.sched_priority=priority;
auto result = pthread_setschedparam(target, policy, &param);
if (result != 0) {
std::stringstream ss;
Expand Down

0 comments on commit de646b4

Please sign in to comment.