模式切换是否发生从用户线程切换到内核线程? [英] Is mode switch occur switching from user thread to kernel thread?

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

问题描述

我对用户/内核线程和模式/上下文切换感到困惑(平台:Linux)
我有两个联系的问题.

I'm confused of user/kernel thread and mode/context switch (Platform: Linux)
I have two linked questions.

(1)下面的句子正确吗?

(1) Is the below sentence right?

如果我进行系统调用,则会发生模式切换(从用户模式到内核模式),最终会发生从用户线程到内核线程的切换.

If I make a system call, then mode switch (user mode to kernel mode) will occur and eventually switching from user thread to kernel thread happens.

由于系统调用只能在内核线程中执行,我认为模式切换必须发生在从用户线程到内核线程的切换中.

Since system call can only be executed in kernel thread, I think mode switch must occur the switching from the user thread to kernel thread.

(2)然后,我们称之为模式切换的开销就是将用户线程切换为内核线程的开销?会有什么样的开销?

(2) Then, what we call the overhead of mode switching is that switching overhead of user thread to kernel thread? What kinds of overhead will there be?

据我所知,
1)上下文切换是将CPU从一个进程或线程切换到另一个进程或线程,并且仅在内核模式下发生.
2)调用模式切换(而不是上下文切换)的原因是,当前正在执行的进程在模式切换期间不会改变.
3)进程上下文切换的成本比线程上下文切换的成本高.

As of I know,
1) Context switching is the switching of the CPU from one process or thread to another and only happens in kernel mode.
2) The reason for calling mode switch (instead of context switching) is that the currently executing process does NOT change during a mode switch.
3) Process context switching costs more than Thread context switching.

推荐答案

(1)下面的句子正确吗?

(1) Is the below sentence right?

如果我进行系统调用,则会发生模式切换(从用户模式到内核模式),并最终发生从用户线程到内核线程的切换.

If I make a system call, then mode switch (user mode to kernel mode) will occur and eventually switching from user thread to kernel thread happens.

(2)然后,我们称之为模式切换的开销就是将用户线程切换为内核线程的开销?会有什么样的开销?

(2) Then, what we call the overhead of mode switching is that switching overhead of user thread to kernel thread? What kinds of overhead will there be?

保存寄存器,更改段选择器等.这个问题的好答案

Saving registers, changing segment selectors, etc. Good answer to this question

模式切换(用户线程到内核线程)和线程上下文切换(内核线程到内核线程)有什么区别?

What is big difference between mode switch (user thread to kernel thread) and thread context switch (kernel thread to kernel thread)?

我认为在将内核线程切换到内核线程的情况下,段选择器是相同的,也许还有一些寄存器.它依赖于架构

I think that segment selectors are the same in case of switching kernel thread to kernel thread, maybe some registers too. It's architecture dependent

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

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