hello world program execution process

Taking the Linux system as an example,
during the execution of the hello world program
, enter a command in the Linux system terminal: echo hello world! Displays the character "hello world!" When the
user enters echo hello world!, the shell program will input each character from the keyboard one by one. Read into the CPU register, then save it to the main memory, and form the string "echo hello world!" in the main memory. When the Enter key is pressed, the shell will call out the linux system's API interface function "echo", hello , world! It is used as a parameter of the echo function. At this time, the system generates a soft interrupt through port 80: int 80, and the parent process creates a child process through fork(). It needs to apply for a blank PCB, allocate the required resources for the process, and initialize it. PCB, add it to the ready queue. When the process's time slice arrives, the operating system sets the CPU context and jumps to the beginning of the program.
The linux system adopts page-based storage management. The first instruction of the program is executed, and a page fault interrupt occurs. At this time, the operating system needs to allocate a page of memory, and call the disk driver through the soft terminal to read the code from the disk. Before reading, the scene needs to be saved, and the scene is restored after the interruption. Linux regards the peripheral as a file, and the data will be transferred into the memory through the read interface. In the future, more page fault interrupts will occur, and more pages will be read in. If a hit occurs, no interrupt will be generated. The display of characters also requires a system call, an interrupt is generated, and a device driver is called. Send the characters to the window system's buffer, tell the window system that it wants to display the string, the window system converts the string to pixels, writes it to the memory image, and the video hardware converts the pixel representation to a set of analog signals, then we can See the output of hello world

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326036592&siteId=291194637