diff options
author | Aleksandar Donchev <Aleksander.Donchev@partner.bmw.de> | 2017-11-27 15:39:53 +0100 |
---|---|---|
committer | Jacqueline Molz <Jacqueline.Molz@bmw.de> | 2018-02-13 12:48:36 +0100 |
commit | d6481481d86408a5b1c74162012167ed57ac6ee9 (patch) | |
tree | 6713f2695103494b2b4fe445fb95f9fe2b629041 /AudioManagerUtilities/include/CAmSocketHandler.h | |
parent | 34207d94acb8914c4f45b64c2362c645251a53ec (diff) | |
download | audiomanager-d6481481d86408a5b1c74162012167ed57ac6ee9.tar.gz |
Cmake parameters for real-time scheduler's priority and policy and throw runtime error if read fails.
Signed-off-by: Christian Linke <christian.linke@bmw.de>
Change-Id: I6a7a2c424bc8fac62c76a66545a231c518edb2e1
Diffstat (limited to 'AudioManagerUtilities/include/CAmSocketHandler.h')
-rw-r--r-- | AudioManagerUtilities/include/CAmSocketHandler.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/AudioManagerUtilities/include/CAmSocketHandler.h b/AudioManagerUtilities/include/CAmSocketHandler.h index 53010ba..2fd5c42 100644 --- a/AudioManagerUtilities/include/CAmSocketHandler.h +++ b/AudioManagerUtilities/include/CAmSocketHandler.h @@ -492,7 +492,29 @@ public: void exit_mainloop(); bool fatalErrorOccurred(); +#ifdef WITH_REALTIME_SCHEDULER + /** + * Set scheduling algorithm and/or parameters for a thread whose ID is specified in pid. + * If pid equals zero, the scheduling policy and parameters of the calling thread will be set. + * @param pid_t pid thread id + * @param int policy equals specified policies in sched_setscheduler documentation + * @param int priority between 1 and 99 + * @return on success 0 and on error -1 + */ + static int setRuntimeScheduler(const pid_t pid, const int policy, const int priority); +#endif }; +#ifdef WITH_REALTIME_SCHEDULER +#define SET_REALTIME_SCHEDULER()\ + if ( CAmSocketHandler::setRuntimeScheduler(0, AM_REALTIME_POLICY, AM_PROCESS_PRIORITY) != 0 )\ + {\ + std::cerr <<"sched_setscheduler:"<<strerror(errno)<<std::endl;\ + std::cerr << "Try running as root"<<std::endl;\ + } +#else +#define SET_REALTIME_SCHEDULER() +#endif + } /* namespace am */ #endif /* SOCKETHANDLER_H_ */ |