blob: e069b83d65fb210ae2872edc22bd68811033cbfe [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 Silvermane4d8b282015-12-24 13:44:48 -080033// Pins the current thread to CPU #number.
34void PinCurrentThreadToCPU(int number);
35
Brian Silverman2fe007c2014-12-28 12:20:01 -080036// Sets the name of the current thread.
37// This will displayed by `top -H`, dump_rtprio, and show up in logs.
38// name can have a maximum of 16 characters.
39void SetCurrentThreadName(const ::std::string &name);
40
Austin Schuh3d4d5df2015-10-17 15:51:41 -070041void LockAllMemory();
42
brians343bc112013-02-10 01:53:46 +000043} // namespace aos
44
Brian Silverman14fd0fb2014-01-14 21:42:01 -080045#endif // AOS_LINUX_CODE_INIT_H_