The relationship between program operation and operating system

The operating environment of the program (native code) is determined by the operating system and hardware

​ The way an application program passes instructions to the operating system is called an API . The APIs of Windows and Unix series operating systems provide a combination of functions that can be used by any application.

Because the APIs of different operating systems are different, when transferring the same application to other operating systems, it is necessary to rewrite the API part used in the application.

​ Functions such as keyboard input equivalent to input and output operations of peripheral devices are provided through API.

​ The UNIX operating system FreeBSD has a mechanism called Ports . This mechanism can compile the source code of the application in combination with the currently running hardware environment, and then obtain a native code system that can be run

The relationship between operating system and application

The prototype of the operating system is a monitoring program that only has the function of loading and running programs . Later, some functions were gradually added to the monitoring program, such as the basic input and output program functions.

The initial operating system = monitoring program + basic input and output program

Therefore, it can be said that the operating system is a collection of multiple programs.

The operating system can be divided into: control program (hardware control, program operation control), programming language processor (assembly, compilation, analysis) and utility programs (text editor, debugging tool, dump program)

The executable file of the application refers to the native code that the computer's CPU can directly interpret and run

The application does not directly control the hardware, but indirectly controls the hardware through the operating system. Similar to the C language time()and printf()the running results of these functions, they are not hardware-oriented 面向操作系统. After the operating system receives the instruction issued by the application, it first interprets the instruction, and then controls the clock IC and display I/O.

The hardware control function of the operating system is usually provided in the form of a collection of some small functions. The behavior of these functions and the called functions are collectively called system calls .

Different operating systems, when writing c source code, printfthe reason why functions can be used in the same way is that they are converted into system calls of the corresponding operating system during compilation (or a combination of multiple system calls). In other words, an application written in a high-level programming language is converted into a native code using system calls after being compiled.

Reference book "How does the program run"

Guess you like

Origin blog.csdn.net/weixin_43865875/article/details/108161962