Definition and realization of operating system interface

1. What is the operating system interface

As a computer user, we generally have three ways to operate the computer:

1 命令行.: That is, through the command program, this method is commonly used in linux systems.
2 图形化界面.: The computer can be controlled by mouse clicks and other operations. The windows system is very good in this respect. This way is realized through the message frame program and message processing program
3.应用程序

Regardless of the method, we need to establish a connection between the operating system and the application. How to establish a connection? This will be used 操作系统接口.

The operating system interface is composed of C language code and some important functions provided by the operating system. The operating system interface is also called系统调用 . We can establish a connection between the application and the operating system through system calls.

2. The realization of the system call

The computer hardware system does not allow us to directly call the functions provided by the operating system kernel through jump instructions such as jmp in the memory , because this may cause the leakage of sensitive information.

To ensure the security of the system, we have designed for the computer hardware 内核态and 用户态the model, kernel mode can access information user mode, but can not access user mode kernel mode .

Insert picture description here
The CPL(Current Privilege Level)initialization result of the user program is 3, and the function in the operating system kernel DPL(Descriptor Privilege Level)is 0 , so the user has insufficient access rights to the kernel.

In order to achieve a system call, the operating system provides a unique method for a user invokes the kernel function to our: 中断指令int. When the program executes to the int instruction, the int instruction will modify the CPL in CS to 0, and when the access to the core ends, reset the CPL to 3 to continue executing the user program .

Insert picture description here
The process after the system call enters the kernel mode:

Insert picture description here

Guess you like

Origin blog.csdn.net/m0_46550452/article/details/108088201