forked from gehee/FPVue_rk
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from OpenHD/consti-dev
Make things a bit nicer to use
- Loading branch information
Showing
4 changed files
with
96 additions
and
19 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,57 @@ | ||
// | ||
// Created by consti10 on 09.04.24. | ||
// | ||
|
||
#ifndef FPVUE_SCHEDULINGHELPER_H | ||
#define FPVUE_SCHEDULINGHELPER_H | ||
|
||
#include <pthread.h> | ||
#include <sys/resource.h> | ||
#include <unistd.h> | ||
|
||
#include <iostream> | ||
#include <sstream> | ||
#include <string> | ||
|
||
namespace SchedulingHelper { | ||
|
||
// Only 'low' in comparison to other realtime tasks | ||
static constexpr int PRIORITY_REALTIME_LOW=30; | ||
static constexpr int PRIORITY_REALTIME_MID=40; | ||
|
||
// this thread should run as close to realtime as possible | ||
// 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 = priority; | ||
auto result = pthread_setschedparam(target, policy, ¶m); | ||
if (result != 0) { | ||
std::stringstream ss; | ||
ss << "Cannot setThreadParamsMaxRealtime " << result; | ||
std::cerr << ss.str() << std::endl; | ||
} else { | ||
std::stringstream ss; | ||
ss << "Changed prio "; | ||
if (!tag.empty()) { | ||
ss << "for " << tag << " "; | ||
} | ||
ss << "to SCHED_FIFO:" << param.sched_priority; | ||
std::cout << ss.str() << std::endl; | ||
} | ||
} | ||
|
||
static bool check_root() { | ||
const auto uid = getuid(); | ||
const bool root = uid ? false : true; | ||
return root; | ||
} | ||
|
||
} // namespace SchedulingHelper | ||
|
||
#endif //FPVUE_SCHEDULINGHELPER_H |
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,3 @@ | ||
#b!in/bash | ||
|
||
./build/fpvue --gst-udp-port 5600 --rmode 5 |