Linux内核中进程的年龄 [英] Age of a process in the Linux kernel
问题描述
给出要使用的struct task_struct
.确定一个流程有多长时间的最佳方法是什么?
Given the struct task_struct
to work with. What's the best way to determine how old a process is?
task_struct
用于保存指向其下一个最小的兄弟姐妹和最大的孩子的特定指针.在某些内核版本中似乎不再可用.
The task_struct
is used to hold specific pointers to it's next youngest sibling, and oldest child. That no longer seems to be available in some kernel versions.
我专门使用Android金鱼内核.我一直在尝试学习如何使用list_head
结构遍历进程,但似乎无法弄清楚如何确定每个孩子或同级进程的年龄.
I'm specifically using the Android goldfish kernel. I've been trying to learn how to use the list_head
structure to iterate over processes, but I can't seem to figure out how to determine the age of each child or sibling process.
那么,task_struct
的哪个成员或用法将执行此操作?
So, what member or usage of task_struct
would do this?
推荐答案
我认为您可以在task_struct中使用real_start_time或start_time. 在创建流程时会对其进行更新
I think you can use real_start_time or start_time in task_struct. It is updated at the time of process creation
struct timespec start_time; /* monotonic time */
struct timespec real_start_time; /* boot based time */
注意:这是普通内核,对Android内核一无所知
Note: this is vanilla kernel no idea about android kernel
这篇关于Linux内核中进程的年龄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!