In its core, the operating system sets up a set of subroutines (i.e. procedures) for implementing various system functions for application invocation. Because of the specificity of the OS system process, the application cannot invoke these processes in a general procedure invocation, but instead use a system invoke command to invoke the desired system procedure. There are several obvious differences between it and the general process invocation.
(1) Run in a different state. General procedure invocation, both the calling program and the invoked program run in the same state as a system state or user state, while in the system call, the calling program usually runs in the user state, and the invoked program runs in the system state.
(2) The conversion of the system State. Because the general procedure call does not involve the transformation of the system State, it can be shifted directly from the calling procedure to the invoked procedure. However, when the system call is run, the calling procedure is not allowed to be directed to the invoked procedure because the call and the invoked procedure are working in different system states. Usually through the soft interrupt mechanism, first from the user state to the system state, after the kernel analysis, can turn to the corresponding system call processing subroutine.
(3) Return question. In a system with preemption (deprivation) scheduling, after the called process is executed, the priority analysis should be made to all the processes that are required to run in the system. When the calling process still has the highest Gao priority, it is returned to the calling process to continue, otherwise it will cause a rescheduling to allow the highest priority process to execute. In this inch, you need to put the calling process into the ready queue.
(4) nested calls. As with normal procedures, system calls can be nested, that is, during the execution of a called procedure, you can also invoke another system call using the system call command. Of course, each system has a certain limit on the depth of the nested call, usually no more than 6 depth. The following figure (a) shows a system call without nesting, as shown in Figure 8-8 (b) with nested system calls.