在Linux下自动调整流程优先级 [英] Automatically adjusting process priorities under Linux

查看:62
本文介绍了在Linux下自动调整流程优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个程序,该程序根据配置文件(基本上是路径-优先级对)自动设置进程优先级.

I'm trying to write a program that automatically sets process priorities based on a configuration file (basically path - priority pairs).

我认为最好的解决方案是替换execve()系统调用的内核模块.不幸的是,系统调用表未在2.6.0内核版本中导出,因此如果没有真正难看的骇客,就无法替换系统调用.

I thought the best solution would be a kernel module that replaces the execve() system call. Too bad, the system call table isn't exported in kernel versions > 2.6.0, so it's not possible to replace system calls without really ugly hacks.

要执行以下操作:

-用shell脚本替换二进制文件,这些脚本会启动和停止二进制文件. -修补/重新编译我的库存Ubuntu内核 -进行丑陋的黑客攻击,例如读取内核可执行内存并猜测syscall表的位置 -正在运行的进程的轮询

-Replace binaries with shell scripts, that start and renice the binaries. -Patch/recompile my stock Ubuntu kernel -Do ugly hacks like reading kernel executable memory and guessing the syscall table location -Polling of running processes

真的想要成为:

-能够根据其可执行路径和配置文件来控制任何进程的优先级.规则适用于任何用户.

-Able to control the priority of any process based on it's executable path, and a configuration file. Rules apply to any user.

你们中的任何人对如何完成此任务有任何想法吗?

Does anyone of you have any ideas on how to complete this task?

推荐答案

如果您已经准备好使用轮询解决方案,那么您要实现的大多数功能都已经存在于

If you've settled for a polling solution, most of the features you want to implement already exist in the Automatic Nice Daemon. You can configure nice levels for processes based on process name, user and group. It's even possible to adjust process priorities dynamically based on how much CPU time it has used so far.

这篇关于在Linux下自动调整流程优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆