John Park | 398c74a | 2018-10-20 21:17:39 -0700 | [diff] [blame] | 1 | #ifndef AOS_INIT_H_ |
| 2 | #define AOS_INIT_H_ |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 3 | |
Brian Silverman | 2fe007c | 2014-12-28 12:20:01 -0800 | [diff] [blame] | 4 | #include <string> |
| 5 | |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 6 | namespace aos { |
| 7 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 8 | // Initializes glog and gflags. |
| 9 | void InitGoogle(int *argc, char ***argv); |
| 10 | |
Brian Silverman | 6da0427 | 2014-05-18 18:47:48 -0700 | [diff] [blame] | 11 | // In order to use shared memory, one of the Init* functions must be called in |
| 12 | // exactly 1 thread per process. It is OK to keep going without calling one of |
| 13 | // them again after fork(2)ing. |
| 14 | |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 15 | // Does the non-realtime parts of the initialization process. |
Brian Silverman | 8f8debf | 2018-03-11 19:30:23 -0700 | [diff] [blame] | 16 | // If for_realtime is true, this sets up to call GoRT later. |
| 17 | void InitNRT(bool for_realtime = false); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 18 | // Initializes everything, including the realtime stuff. |
Brian Silverman | f3cfbd7 | 2013-10-28 16:26:09 -0700 | [diff] [blame] | 19 | // relative_priority adjusts the priority of this process relative to all of the |
| 20 | // other ones (positive for higher priority). |
| 21 | void Init(int relative_priority = 0); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 22 | // Same as InitNRT, except will remove an existing shared memory file and create |
| 23 | // a new one. |
| 24 | void InitCreate(); |
| 25 | // Cleans up (probably not going to get called very often because few things can |
| 26 | // exit gracefully). |
| 27 | void Cleanup(); |
| 28 | |
Brian Silverman | 8f8debf | 2018-03-11 19:30:23 -0700 | [diff] [blame] | 29 | // Performs the realtime parts of initialization after InitNRT(true) has been called. |
| 30 | void GoRT(int relative_priority = 0); |
| 31 | |
Brian Silverman | e4d8b28 | 2015-12-24 13:44:48 -0800 | [diff] [blame] | 32 | // Pins the current thread to CPU #number. |
| 33 | void PinCurrentThreadToCPU(int number); |
| 34 | |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 35 | } // namespace aos |
| 36 | |
John Park | 398c74a | 2018-10-20 21:17:39 -0700 | [diff] [blame] | 37 | #endif // AOS_INIT_H_ |