blob: e34ecfd6f3a5e0da3d3cc6ea700600b3730584a7 [file] [log] [blame]
Brian Silverman14fd0fb2014-01-14 21:42:01 -08001#ifndef AOS_LINUX_CODE_INIT_H_
2#define AOS_LINUX_CODE_INIT_H_
brians343bc112013-02-10 01:53:46 +00003
Brian Silverman2fe007c2014-12-28 12:20:01 -08004#include <string>
5
brians343bc112013-02-10 01:53:46 +00006namespace aos {
7
Brian Silverman6da04272014-05-18 18:47:48 -07008// In order to use shared memory, one of the Init* functions must be called in
9// exactly 1 thread per process. It is OK to keep going without calling one of
10// them again after fork(2)ing.
11
brians343bc112013-02-10 01:53:46 +000012// Does the non-realtime parts of the initialization process.
13void InitNRT();
14// Initializes everything, including the realtime stuff.
Brian Silvermanf3cfbd72013-10-28 16:26:09 -070015// relative_priority adjusts the priority of this process relative to all of the
16// other ones (positive for higher priority).
17void Init(int relative_priority = 0);
brians343bc112013-02-10 01:53:46 +000018// Same as InitNRT, except will remove an existing shared memory file and create
19// a new one.
20void InitCreate();
21// Cleans up (probably not going to get called very often because few things can
22// exit gracefully).
23void Cleanup();
24
Brian Silvermanfe1ef172014-04-12 17:12:45 -070025// Sets up this process to write core dump files.
Brian Silverman6da04272014-05-18 18:47:48 -070026// This is called by Init*, but it's here for other files that want this
27// behavior without calling Init*.
Brian Silvermanfe1ef172014-04-12 17:12:45 -070028void WriteCoreDumps();
29
Brian Silvermanda45b6c2014-12-28 11:36:50 -080030// Sets the current thread's realtime priority.
31void SetCurrentThreadRealtimePriority(int priority);
32
Brian Silvermana70994f2017-03-16 22:32:55 -070033// Sets the current thread back down to non-realtime priority.
34void UnsetCurrentThreadRealtimePriority();
35
Brian Silvermane4d8b282015-12-24 13:44:48 -080036// Pins the current thread to CPU #number.
37void PinCurrentThreadToCPU(int number);
38
Brian Silverman2fe007c2014-12-28 12:20:01 -080039// Sets the name of the current thread.
40// This will displayed by `top -H`, dump_rtprio, and show up in logs.
41// name can have a maximum of 16 characters.
42void SetCurrentThreadName(const ::std::string &name);
43
Austin Schuh3d4d5df2015-10-17 15:51:41 -070044void LockAllMemory();
45
brians343bc112013-02-10 01:53:46 +000046} // namespace aos
47
Brian Silverman14fd0fb2014-01-14 21:42:01 -080048#endif // AOS_LINUX_CODE_INIT_H_