Linux   发布时间:2022-03-31  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了linux – struct task_struct中字段’on_cpu’和struct thread_info中字段’cpu’的含义是什么?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我想知道 Linux系统中当前进程正在运行哪个cpu, 我有两个选择 – >在struct task_struct或中获取字段on_cpu >在struct thread_info中获取字段cpu. 我编写了一个内核模块编程来探测这两个字段,然后得到 结果如下: [ 3991.419185] the field 'on_cpu' in task_struct is :1 [ 3991.419187
我想知道 Linux系统中当前进程正在运行哪个cpu,
我有两个选择 – @H_607_20@ @H_607_20@>在struct task_struct或中获取字段on_cpu
>在struct thread_info中获取字段cpu.

@H_607_20@我编写了一个内核模块编程来探测这两个字段,然后得到
结果如下:

@H_607_20@
[ 3991.419185] the field 'on_cpu' in task_struct is :1
[ 3991.419187] the field 'cpu' in thread_info is :0
[ 3991.419199] the field 'on_cpu' in task_struct is :1
[ 3991.419200] the field 'cpu' in thread_info is :0
[ 3991.419264] the field 'on_cpu' in task_struct is :1
[ 3991.419266] the field 'cpu' in thread_info is :1
[ 3991.419293] the field 'on_cpu' in task_struct is :1
[ 3991.419294] the field 'cpu' in thread_info is :1
[ 3991.419314] the field 'on_cpu' in task_struct is :1
[ 3991.419315] the field 'cpu' in thread_info is :1
[ 3991.419494] the field 'on_cpu' in task_struct is :1
[ 3991.419495] the field 'cpu' in thread_info is :0
[ 3991.419506] the field 'on_cpu' in task_struct is :1
[ 3991.419507] the field 'cpu' in thread_info is :1
@H_607_20@我不知道这两个领域的正确含义.

解决方法

thread_info中的cpu字段指定执行进程的cpu的编号.这就是你要搜索内容. @H_607_20@ @H_607_20@task_struct中的on_cpu标志实际上是上下文切换时的锁定,并且希望在上下文切换期间启用中断,以便通过解锁的runqueue来避免高延迟.基本上当它为0时,任务可以移动到不同的cpu.

大佬总结

以上是大佬教程为你收集整理的linux – struct task_struct中字段’on_cpu’和struct thread_info中字段’cpu’的含义是什么?全部内容,希望文章能够帮你解决linux – struct task_struct中字段’on_cpu’和struct thread_info中字段’cpu’的含义是什么?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。