本文介绍了什么是在内核模式线程(和流程),那些在用户模式之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题:

1)在书中的现代操作系统的,它说,线程和进程可以在内核模式或用户模式,但它并没有说清楚什么是它们之间的区别。

1)In book modern operating system, it says the threads and processes can be in kernel mode or user mode, but it does not say clearly what's the difference between them .

2)为什么在内核模式线程和进程交换机的成本比用户模式线程和进程?

2)Why the switch for the kernel-mode threads and process costs more than the switch for user-mode threads and process?

3)现在,我学习Linux的,我想知道我将如何在内核模式和用户模式分别创建线程和进程的Linux系统?

3) now, I am learning Linux,I want to know how would I create threads and processes in Kernel mode and user mode respectively IN LINUX SYSTEM?

4)在书的现代操作系统的,它说,它可能是过程将是用户模式,但是这是在用户模式的进程所创建的线程可以在内核模式。这怎么会是可能的?

4)In book modern operating system, it says that it is possible that process would be in user- mode, but the threads which are created in the user-mode process can be in kernel mode. How would this be possible?

推荐答案

用户模式线程是由在这个过程中一些计划在用户模式,这个过程本身是由内核调度处理的唯一的东西。

User-mode threads are scheduled in user mode by something in the process, and the process itself is the only thing handled by the kernel scheduler.

这意味着你的处理的获取一定量从CPU咕噜的,你必须所有的用户模式下的线程之间共享。

That means your process gets a certain amount of grunt from the CPU and you have to share it amongst all your user mode threads.

简单的情况下,你有两个过程,一个有一个线程,一个个有100个线程。

Simple case, you have two processes, one with a single thread and one with a hundred threads.

通过一个简单的内核调度策略,在单线程程序线程获取CPU的50%,在百元线程进程中每个线程获取每个0.5%。

With a simplistic kernel scheduling policy, the thread in the single-thread process gets 50% of the CPU and each thread in the hundred-thread process gets 0.5% each.

通过内核模式线程,内核本身独立地管理你的线程和调度他们。使用相同的简单的调度程序,每个线程将获得刚下CPU咕噜1%的触摸(101线程共享CPU的100%)。

With kernel mode threads, the kernel itself manages your threads and schedules them independently. Using the same simplistic scheduler, each thread would get just a touch under 1% of the CPU grunt (101 threads to share the 100% of CPU).

在为什么内核模式切换为更昂贵的术语,它可能有与您需要切换到内核模式去做的事实做。用户模式的线程做自己的东西,在用户模式(明显),所以没有涉及线程切换操作内核。

In terms of why kernel mode switching is more expensive, it probably has to do with the fact that you need to switch to kernel mode to do it. User mode threads do all their stuff in user mode (obviously) so there's no involving the kernel in a thread switch operation.

在Linux下,你创建一个线程 克隆 打电话,类似于,但超过的东西更精细的控制。

Under Linux, you create threads (and processes) with the clone call, similar to fork but with much finer control over things.

您最后一点是有点钝。我不能肯定,但它可能在谈论用户和内核模式在这个意义上,人们可以将执行用户code和另一个可以做在内核中的一些系统调用(这需要切换到内核或超级模式)。

Your final point is a little obtuse. I can't be certain but it's probably talking about user and kernel mode in the sense that one could be executing user code and another could be doing some system call in the kernel (which requires switching to kernel or supervisor mode).

这是在谈论线程支持(线程用户或内核模式支持)时,是不一样的区别。无需书手的副本,我不能说确切,但是这会是我最好的猜测。

That's not the same as the distinction when talking about the threading support (user or kernel mode support for threading). Without having a copy of the book to hand, I couldn't say definitively, but that'd be my best guess.

这篇关于什么是在内核模式线程(和流程),那些在用户模式之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 18:19