如何查找给定时刻Linux操作系统正在运行哪个进程?

发布于 2024-07-25 21:14:00 字数 139 浏览 3 评论 0原文

因此,操作系统在给定时刻执行多任务并运行一个进程(假设它是一台单核机器)。 有没有一种方法可以跟踪/轮询并查找哪个进程在什么时间运行以及什么时间将其放入队列并检索回来。 是否有任何系统调用? 有没有一种方法可以在不修改Linux内核源代码的情况下实现这一点。

So a OS multi-tasks and runs one process at a given moment (assuming it's a single core machine). Is there a way I can track/poll and find which process was running at what time and at what time it was put in the queue and retrieved back. Are there any system calls for this ?. Is there a way to achieve this without modifying the linux kernel's source.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你穿错了嫁妆 2024-08-01 21:14:00

我认为你需要 lttng,它绝对能让你对系统的任务切换有一个详细的了解(还有更多)比那)与 lttng 查看器。 Lttng的内核部分已经合并到当前的Linux内核中,如果您的内核启用了此功能,您就可以使用它。 这里是 lttng 的一些屏幕截图。

I think you need lttng, it definitely give a you a elaborate view of the system's task switch thing(and much more than that) with the lttng viewer. Lttng's kernel part has been merged to current Linux kernel, and you can use it if your kernel has enabled this feature. Here is some screen shots for lttng.

失去的东西太少 2024-08-01 21:14:00

我不认为你能在本地做到这一点。 AFAIK linux 不会记录此信息的历史记录。

I don't think you can do this natively. AFAIK linux does not a keep a history track of this information.

阳光下的泡沫是彩色的 2024-08-01 21:14:00

这是一个不合逻辑的问题。 如果您从脚本/进程查询操作系统,那么活动程序就是......您的。

不过我想如果您想要历史记录,您可以观看 /proc 目录或 ps 的输出

That's an illogical question. If you are querying the OS from a script/process then the active program is ... YOURS.

Though I guess if you want the history you could watch the /proc directory or the output from ps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文