1# Startup in User Space<a name="EN-US_TOPIC_0000001123640059"></a> 2 3- [Startup of the Root Process in User Space](#section79911135647) 4 - [Startup Process of the Root Process](#section1184317581349) 5 - [Responsibilities of the Root Process](#section1590220321759) 6 7- [Running Programs in User Space](#section194576310611) 8 9## Startup of the Root Process in User Space<a name="section79911135647"></a> 10 11The root process is the first user-space process in the system. The process ID is 1. The root process is the ancestor of all user-space processes. 12 13**Figure 1** Process tree<a name="fig427516409375"></a> 14 15 16### Startup Process of the Root Process<a name="section1184317581349"></a> 17 18Use the link script to place the following init startup code to the specified location in the system image. 19 20``` 21#define LITE_USER_SEC_ENTRY __attribute__((section(".user.entry"))) 22LITE_USER_SEC_ENTRY VOID OsUserInit(VOID *args) 23{ 24#ifdef LOSCFG_KERNEL_DYNLOAD 25 sys_call3(__NR_execve, (UINTPTR)g_initPath, 0, 0); 26#endif 27 while (true) { 28 } 29} 30``` 31 32During system startup, **OsUserInitProcess** is called to start the **init** process. The process is as follows: 33 341. The kernel calls **OsLoadUserInit** to load the code. 352. A process space is created to start the **/bin/init** process. 36 37### Responsibilities of the Root Process<a name="section1590220321759"></a> 38 39- Starts key system programs or services, such as shell. 40 41 > **NOTE:** 42 >In OpenHarmony, the **init** process reads the **/etc/init.cfg** file and runs specified commands or starts specified processes based on configurations. For details, see [init Module](../subsystems/subsys-boot-init.md). 43 44 45- Monitors the process for reclaiming the orphan process and clears the zombie processes in child processes. 46 47## Running Programs in User Space<a name="section194576310611"></a> 48 49Common compilation modes of user-space programs include: 50 511. [Compilation using the framework](../quick-start/quickstart-lite-steps-hi3516-running.md) 522. Manual compilation 53 54 Example: 55 56 ``` 57 clang --target=arm-liteos --sysroot=prebuilts/lite/sysroot -o helloworld helloworld.c 58 ``` 59 60 Before running the **clang** command, install the LLVM compiler. For details, see [Installing LLVM](../quick-start/quickstart-lite-env-setup-linux.md). 61 62 **--target=arm-liteos**: specifies that the compilation platform is arm-liteos. 63 64 **--sysroot=$\{YOUR\_ROOT\_PATH\}/prebuilts/lite/sysroot**: specifies the directory in which you can search for the header file and the dependent standard libraries. 65 66 67A user-space program can be started in either of the following ways: 68 69- Run the shell command to start the process. 70 71 ``` 72 OHOS $ exec helloworld 73 OHOS $ ./helloworld 74 OHOS $ /bin/helloworld 75 ``` 76 77 78- Start a new process by calling the POSIX API. 79 80 Use the **Fork\(\)** method to create a process, and call the **exec\(\)** method to execute a new process. 81 82 83