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