System call instructions, differences and connections between access control instructions

When there is a requirement for operating system services in the source program, the compiler will arrange a "visit instruction" and set some parameters in the target program converted from the source program. When the target program is executed, if the central processor obtains the "visit control instruction", an interrupt event is generated, and the interrupt device converts the central processor into the managed state and allows the operating system to handle the interrupt event. The operating system analyzes the parameters in the access control instruction, and then allows the corresponding "system call" subroutine to serve the user. Secondly, the visit control instruction is the instruction used in the state of mind.

       We know that user programs can only be run in the current state, and privileged instructions cannot be used. So there is such a question: What should I do if the user program wants to start a peripheral, or wants to complete a job that cannot be done in the current state? There are three conditions to solve this problem:

  (1) An instruction is required to enable the processor to enter the management state from the target state and submit the work to be completed on behalf of the operating system;

  (2) Under the control state, the operating system completes the request of the user program;

  (3) The operating system can return to the user program after completing the work, that is, return to the original state from the management state.

   To solve this problem depends on the visit control instructions. The access control instruction itself is not a privileged instruction, and its basic function is to allow the program to have a "voluntary access" method, which causes the access control interruption.

  There are also some materials that I find myself. The access control instruction is composed of two parts: the instruction code and the access control interrupt number, namely  SVC n, formula (1) where SVC (super visor call) is the instruction code, indicating that it is the access control instruction; n is The access control interrupt number, whose value is an integer, specifically indicates what kind of access request. When an interrupt occurs, the hardware terminal device sends the access control interrupt number n to the interrupt code field in the old program status word. The access control interrupt control program is taken out from the system stack and transferred to the corresponding service program accordingly in. (There is a bit of attention here, the system call program is determined based on the visit interrupt number).

  In actual use, the user program and the operating system also need to pass parameters and return values ​​to each other. Therefore, the general form of user access control instructions is: preparation parameters; SVC n; take the return value formula (2). According to specific housekeeping requirements, the parameters and return value can be passed through registers or through memory. For the latter, the operating system must be able to access the process space.

  Generally, the formula (2) is called a system call instruction. In addition to the access control instruction, it also has a preparation parameter and a return value. For the convenience of use, it is generally written in a form similar to the procedure call in high-level languages, namely: return value = system call name (parameter 1, parameter 2, ..., parameter n) Equation (3). Of course, the compiler will translate equation (3) into the form of (2). Among them, the system call name corresponds to equation (1), and different system call names correspond to different integers n. In some books, formula (3) is also called a macro instruction or a generalized instruction representing formula (2) .

Guess you like

Origin www.cnblogs.com/cy13blogs/p/12711152.html
Recommended