Automatically adjusting process priorities under Linux

前端 未结 7 1511
眼角桃花
眼角桃花 2021-02-20 11:52

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

I thought the best solution wo

7条回答
  •  爱一瞬间的悲伤
    2021-02-20 12:49

    If you want to do it as a kernel module then you could look into making your own binary loader. See the following kernel source files for examples:

    $KERNEL_SOURCE/fs/binfmt_elf.c
    $KERNEL_SOURCE/fs/binfmt_misc.c
    $KERNEL_SOURCE/fs/binfmt_script.c
    

    They can give you a first idea where to start.

    You could just modify the ELF loader to check for an additional section in ELF files and when found use its content for changing scheduling priorities. You then would not even need to manage separate configuration files, but simply add a new section to every ELF executable you want to manage this way and you are done. See objcopy/objdump of the binutils tools for how to add new sections to ELF files.

提交回复
热议问题