简体   繁体   English

如何计算旧内核上的自愿上下文切换

[英]how to count voluntary context switches on older kernel

I want to find the number of voluntary context switches for a given pid. 我想找到给定pid的自愿上下文切换的数量。

I can find this using /proc/pid/status but non voluntary and voluntary context switches info was added from kernel 2.6.23. 我可以使用/ proc / pid / status找到它,但是从内核2.6.23添加了非自愿和自愿上下文切换信息。

I have to get this info on an older kernel. 我必须在较旧的内核上获取此信息。 How can I do that ? 我怎样才能做到这一点 ? My kernel version is -- 2.6.18 我的内核版本是-2.6.18

man page for proc entry that mentions the kernel version for this info -- http://man7.org/linux/man-pages/man5/proc.5.html proc条目的手册页,其中提到了此信息的内核版本-http: //man7.org/linux/man-pages/man5/proc.5.html

As far as I remember this old kernel has not supported TRACE EVENTS yet. 据我所知,这个旧内核还不支持TRACE EVENTS。 So, may be you should hack your kernel ))). 因此,也许您应该破解您的内核)))。 Eg add counter in struct task_struct and will be increment when context is switched. 例如在struct task_struct中添加计数器,并且在切换上下文时将增加。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM