blob: 9b0c3d6076535eea92dae6d4593fb68fa60c6ff6 [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 Silverman2fe007c2014-12-28 12:20:01 -080033// Sets the name of the current thread.
34// This will displayed by `top -H`, dump_rtprio, and show up in logs.
35// name can have a maximum of 16 characters.
36void SetCurrentThreadName(const ::std::string &name);
37
Austin Schuh3d4d5df2015-10-17 15:51:41 -070038void LockAllMemory();
39
brians343bc112013-02-10 01:53:46 +000040} // namespace aos
41
Brian Silverman14fd0fb2014-01-14 21:42:01 -080042#endif // AOS_LINUX_CODE_INIT_H_