Custom threads vs kernel threads

Can someone help clarify my understanding of kernel threads. I heard that on Linux / Unix, kernel threads (like system calls) run faster than user threads. But aren't these user threads scheduled by the kernel and executed using kernel threads? can someone please tell me what is the difference between a kernel thread and a user thread different from the fact that they have access to different address spaces. what's the difference between them? Is it true that on one processor field, when the user thread is started, the kernel will be suspended?

Thanks in advance,

Alex

+4
source share
1 answer

I heard that on Linux / Unix, kernel threads (like system calls) run faster than user threads.

This is a rather inaccurate statement.

  • Kernel threads are used for background tasks internal to the kernel, such as handling interrupts and deleting data to disk. The bulk of system calls are handled by the kernel in the context of the process that called them.

  • Kernel threads are scheduled more or less in the same way as user processes. Some kernel threads have a higher default priority (in some cases, up to real-time priority), but they are said to be "faster to execute" misleading.

Is it true that on one processor field, when the user thread is launched, the kernel will be suspended?

Sure. Only one process can work per processor.

There are a number of situations where the kernel can interrupt a running task and switch to another (which may be the kernel):

  • When the timer is interrupted. By default, this happens 100 times per second.
  • When a task calls a lock system call (for example, select() or read() ).
  • When a CPU error occurs in a task (for example, a memory access error).
+7
source

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


All Articles