blob: 6e0a47242c2fe68ca05354cb6e5a7ead64ea4044 [file] [log] [blame]
Alex Perrycb7da4b2019-08-28 19:35:56 -07001#ifndef AOS_REALTIME_H_
2#define AOS_REALTIME_H_
3
Brian Silverman6a54ff32020-04-28 16:41:39 -07004#include <sched.h>
James Kuszmaul57c2baa2020-01-19 14:52:52 -08005#include <string_view>
Alex Perrycb7da4b2019-08-28 19:35:56 -07006
7namespace aos {
8
9// Locks everything into memory and sets the limits. This plus InitNRT are
10// everything you need to do before SetCurrentThreadRealtimePriority will make
11// your thread RT. Called as part of ShmEventLoop::Run()
12void InitRT();
13
14// Sets the current thread back down to non-realtime priority.
15void UnsetCurrentThreadRealtimePriority();
16
17// Sets the name of the current thread.
18// This will displayed by `top -H`, dump_rtprio, and show up in logs.
19// name can have a maximum of 16 characters.
James Kuszmaul57c2baa2020-01-19 14:52:52 -080020void SetCurrentThreadName(const std::string_view name);
Alex Perrycb7da4b2019-08-28 19:35:56 -070021
22// Sets the current thread's realtime priority.
23void SetCurrentThreadRealtimePriority(int priority);
24
Brian Silverman6a54ff32020-04-28 16:41:39 -070025// Sets the current thread's scheduling affinity.
26void SetCurrentThreadAffinity(const cpu_set_t &cpuset);
27
Alex Perrycb7da4b2019-08-28 19:35:56 -070028// Sets up this process to write core dump files.
29// This is called by Init*, but it's here for other files that want this
30// behavior without calling Init*.
31void WriteCoreDumps();
32
33void LockAllMemory();
34
James Kuszmaulb4874eb2020-01-18 17:50:35 -080035void ExpandStackSize();
36
Alex Perrycb7da4b2019-08-28 19:35:56 -070037} // namespace aos
38
39#endif // AOS_REALTIME_H_