Is the user space process crowding out the kernel thread?

I am currently reading Understanding the Linux Kernel 3rd Edition and on page 22. I can read:

In the simplest case, the CPU executes the kernel control path sequentially from the first instruction to the last. However, when one of the following events occurs, the CPU interleaves the kernel control paths:

  • A user-mode process calls a system call and the appropriate kernel control path checks that the request cannot be satisfied immediately; This then calls the scheduler to select a new process to start. As a result, a switch process occurs. The first kernel control path remains incomplete, and the CPU resumes some other kernel control path. In this case, two control paths are executed on behalf of two different processes.

Can a kernel control path be interrupted from a user space process making a system call? I thought the priority was pretty much:

  • interrupts
  • kernel threads
  • user space processes

I checked the errors and could not find anything about it.

+6
source share
1 answer

You are right on the priority list, but what (I think) is what this book is trying to say:

  • When a (user) process makes a system call, the kernel starts on its behalf.
  • If the system call can be completed (the kernel control path is not started in the roadblock), it usually returns directly to the calling process - I think getpid() a function call.
  • On the other hand, if the system call cannot be completed (for example, since the disk system must read a block into the kernel buffer pool before its data can be returned to the calling process), then the scheduler is used to select a new process to start - crowding out the user process (thread of control kernel executed on behalf of).
  • At one time, the original system call will continue, and the original (kernel thread control process, executed on behalf of) will continue and, ultimately, be completed, returning control to user space; the process runs in user space, and not in the kernel.

So, β€œNo”: it’s not that β€œthe kernel path can be interrupted from the user space process making the system call”.

The kernel path may be interrupted during the execution of a system call on behalf of the user space process, because: an interrupt occurs or the kernel path must wait until the resource becomes available, or ...

+4
source

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


All Articles