在用户和内核模式线程 [英] Threads in User and kernel mode

查看:131
本文介绍了在用户和内核模式线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们怎么通过线程运行在用户模式和内核模式下运行意味着什么呢?难道这涉及到线程从用户模式执行指令和线程从内核模式执行的指令?请详细说明。
此外,有可能的,如果一个线程在用户模式下执行放置到挂起状态,那么它可能会开始在内核模式下执行?如果是的话,怎么可能?到现在为止,我只知道,如果暂停的线程将被完全停止,即上下文切换将发生由CPU来安排另一个线程。


解决方案

  

我们怎么通过线程是指运行在用户模式和内核模式下运行?


有没有办法知道一个人没有通过上下文中的短语的意思。如果我猜,我说,他们都在谈论线程是否是由一个用户空间调度程序或内核调度计划。但它也有可能他们实际上是问线程是否正在运行用户code或内核code。


  

这是有关线程从用户模式执行指令和线程从内核模式执行的指令?请详细说明。


这可能是。它也可能不是。有没有办法知道一个人没有通过上下文句话的意思。


  

此外,是有可能,如果一个线程在用户模式下执行放置到挂起状态,那么它可能会开始在内核模式下执行?如果是的话,怎么可能?


有关,其中内核调度线程,调度程序运行在内核空间实现。的code实际上挂起线程通常在内核空间中运行过,因为它必须在线程添加到各个内核调度数据结构。这样将恢复线程的线程将运行在内核空间了。在更高的层面来看,执行的同一个线程可以变成内核调度,选择一个用户空间线程来执行,然后变成了线程。


  

到现在为止我只知道,如果暂停将完全挂起的线程,即上下文切换将发生由CPU来安排另一个线程。


对了,这就是内核code。因此,相同的核心运行用户空间code,那么它的运行内核code,那么它的运行另一个线程的用户空间code。

what do we mean by thread running in User mode and running in kernel mode? Is this related to thread execution instruction from User mode and thread executing instruction from Kernel mode? Kindly elaborate. Also, is it possible that if a thread is executing in user mode is put to suspended state, then it may start executing in kernel mode? if yes, how is it possible? Until now I am only aware that a thread if suspended will be SUSPENDED completely, i.e. the context switch will take place by CPU to schedule another thread.

解决方案

what do we mean by thread running in User mode and running in kernel mode?

There is no way to know what a person means by a phrase without context. If I had to guess, I'd say they are talking about whether the thread is scheduled by a user-space scheduler or a kernel scheduler. But it's also possible they are actually asking whether the thread is running user code or kernel code.

Is this related to thread execution instruction from User mode and thread executing instruction from Kernel mode? Kindly elaborate.

It could be. It also might not be. There's no way to know what a person means by a phrase without context.

Also, is it possible that if a thread is executing in user mode is put to suspended state, then it may start executing in kernel mode? if yes, how is it possible?

For implementations where the kernel schedules threads, the scheduler is running in kernel space. The code that actually suspends the thread typically runs in kernel space too because it has to add the thread to the various kernel scheduler data structures. So the thread that resumes the thread will run in kernel space too. At a higher level view, the same thread of execution can "become" the kernel scheduler, choose a user-space thread to execute, and then "become" that thread.

Until now I am only aware that a thread if suspended will be SUSPENDED completely, i.e. the context switch will take place by CPU to schedule another thread.

Right, and that's kernel code. So the same core is running user space code, then it's running kernel code, then it's running the user space code of another thread.

这篇关于在用户和内核模式线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆