linux – struct task_struct中字段’on_cpu’和struct thread_info中字段’cpu’的含义是什么?

linux – struct task_struct中字段’on_cpu’和struct thread_info中字段’cpu’的含义是什么?,第1张

概述我想知道 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,
我有两个选择 –

>在struct task_struct或中获取字段on_cpu
>在struct thread_info中获取字段cpu.

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

[ 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

我不知道这两个领域的正确含义.

解决方法 thread_info中的cpu字段指定执行进程的cpu的编号.这就是你要搜索的内容.

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’的含义是什么?所遇到的程序开发问题。

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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1019603.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存