User mode and kernel mode switching during system calls

At a wide level, which of the following occurs during a linux system call.

  • The user-mode process enters kernel mode and executes kernel code (interrupt service routines), and then returns to normal mode. In other words, the user process consumes the processor.
  • There is a kernel process that always runs in kernel mode. User mode handles sending tasks (in the form of system calls) to the kernel process. The kernel process exits and returns the results to user-mode processes. In other words, the user process is inactive at this time, and the kernel process is one processor consuming.
  • Something else.
+4
source share
2 answers

This is primarily 1, but a little 2.

From the point of view of the usermode application, system calls occur synchronously. Often, however, the system call does not have what it needs to return, so it makes the process sleep. This does not always happen; some simple system calls actually end up synchronously. Some, however, need to wait for the completion of the lengthy I / O task.

, . , , , , , , . , , , , .

, , , .

+2

( ), . , .

[ , Intel...] (, , , ) , . , . , . , . № 2, CPU (0, 1, 2).

, .

, , , , . exception/interrupt, .

, # 1 .

№2 . , ( Linux , ).

, , , , . , , , - . -. - . , , -.

+1

Source: https://habr.com/ru/post/1674302/


All Articles