context_switch( )

context_switch( )上下文切换:
  • 调用switch_mm(),把虚拟内存从一个进程映射切换到新进程中
  • 调用switch_to(),从上一个进程的处理器状态切换到新进程的处理器状态。这包括保存、恢复栈信息和寄存器信息
    The context_switch( ) function sets up the address space of next. the active_mm field of the process descriptor points to the memory descriptor that is used by the process, while the mm field points to the memory descriptor owned by the process. For normal processes, the two fields hold the same address; however, a kernel thread does not have its own address space and its mm field is always set to NULL. The context_switch( ) function ensures that if next is a kernel thread, it uses the address space used by prev.
    context_switch( )函数建立next的地址空间。进程描述符的active_mm字段指向进程所使用的内存描述符,而mm字段
指向进程所拥有的内存描述符。对于一般的进程,这两个字段有相同的地址,但是,内核线程没有它自己的地址空间而且它的 mm字段总是被设置为 NULL。context_switch( )函数保证:如果next是一个内核线程,它使用prev所使用的地址空间:

static inlin
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
上下文切换(Context Switch)是指在操作系统中,当一个进程或线程被暂停执行,而另一个进程或线程被调度并开始执行时,系统需要保存当前进程或线程的上下文信息,并加载下一个进程或线程的上下文信息。这个过程被称为上下文切换。上下文切换的目的是实现多任务并发执行,提高系统的资源利用率和响应性能。 在Windows系统中,可以使用性能计数器来监控上下文切换的变化趋势。可以添加System\Context Switches/sec或Thread(_Total)\Context Switches/sec计数器来进行性能分析。此外,还可以使用工具如Process Explorer来查看进程的上下文切换情况,可以添加Context Switches和Context Switches Delta列来显示上下文切换的信息。进程的属性中的Threads标签页也可以查看线程对应的上下文切换情况。 在一些特定的代码中,也可以通过一些函数或指令来进行上下文切换。例如,在某些代码中可以使用fpsimd_thread_switch、tls_thread_switch、hw_breakpoint_thread_switchcontextidr_thread_switch等函数或指令来进行上下文切换,这些与硬件跟踪相关的操作可以实现特定的上下文切换功能。 #### 引用[.reference_title] - *1* *2* [Context Switches上下文切换性能详解](https://blog.csdn.net/u011391839/article/details/107493267)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [进程切换(context_switch)代码分析:基本逻辑](https://blog.csdn.net/zdy0_2004/article/details/54871189)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值