首页 > 其他分享 >使用busybox自代chrt提升全部TID优先级

使用busybox自代chrt提升全部TID优先级

时间:2023-10-17 11:23:24浏览次数:43  
标签:busybox chrt SCHED policy pid current scheduling TID new

背景

嵌入式平台比较青睐busybox提高设备安全性
其中内建了chrt可以方便的修改调度优先策略

问题

实际使用过程中发现chrt不能统一修改全部thread的优先级

chrt
    chrt [ OPTIONS ] [ PRIO ] [ PID | PROG [ ARGS ]]
    Manipulate real-time attributes of a process

    Options:

    -p      Operate on pid
    -r      Set scheduling policy to SCHED_RR
    -f      Set scheduling policy to SCHED_FIFO
    -o      Set scheduling policy to SCHED_OTHER
    -m      Show min and max priorities

原因是缺少-a参数无法修改PID下全部的TID默认只修改main函数产生的main thread

实现

既然无法自动修改,寻求手动修改方法,声明一个shell function达成效果。

# use self-defined function
promote(){ for i in `ls /proc/${1}/task/`;do chrt -r -p 99 ${i};done; }

效果输出

# promote 4539
pid 4539's current scheduling policy: SCHED_OTHER
pid 4539's current scheduling priority: 0
pid 4539's new scheduling policy: SCHED_RR
pid 4539's new scheduling priority: 99
pid 4540's current scheduling policy: SCHED_OTHER
pid 4540's current scheduling priority: 0
pid 4540's new scheduling policy: SCHED_RR
pid 4540's new scheduling priority: 99
pid 4541's current scheduling policy: SCHED_OTHER
pid 4541's current scheduling priority: 0
pid 4541's new scheduling policy: SCHED_RR
pid 4541's new scheduling priority: 99
pid 4542's current scheduling policy: SCHED_OTHER
pid 4542's current scheduling priority: 0
pid 4542's new scheduling policy: SCHED_RR
pid 4542's new scheduling priority: 99
pid 4543's current scheduling policy: SCHED_OTHER
pid 4543's current scheduling priority: 0
pid 4543's new scheduling policy: SCHED_RR
pid 4543's new scheduling priority: 99
pid 4544's current scheduling policy: SCHED_OTHER
pid 4544's current scheduling priority: 0
pid 4544's new scheduling policy: SCHED_RR
pid 4544's new scheduling priority: 99
pid 4551's current scheduling policy: SCHED_OTHER
pid 4551's current scheduling priority: 0
pid 4551's new scheduling policy: SCHED_RR
pid 4551's new scheduling priority: 99
pid 4559's current scheduling policy: SCHED_OTHER
pid 4559's current scheduling priority: 0
pid 4559's new scheduling policy: SCHED_RR
pid 4559's new scheduling priority: 99
pid 4560's current scheduling policy: SCHED_OTHER
pid 4560's current scheduling priority: 0
pid 4560's new scheduling policy: SCHED_RR
pid 4560's new scheduling priority: 99
pid 4561's current scheduling policy: SCHED_OTHER
pid 4561's current scheduling priority: 0
pid 4561's new scheduling policy: SCHED_RR
pid 4561's new scheduling priority: 99
pid 4562's current scheduling policy: SCHED_OTHER
pid 4562's current scheduling priority: 0
pid 4562's new scheduling policy: SCHED_RR
pid 4562's new scheduling priority: 99
pid 4563's current scheduling policy: SCHED_OTHER
pid 4563's current scheduling priority: 0
pid 4563's new scheduling policy: SCHED_RR
pid 4563's new scheduling priority: 99
pid 4564's current scheduling policy: SCHED_OTHER
pid 4564's current scheduling priority: 0
pid 4564's new scheduling policy: SCHED_RR
pid 4564's new scheduling priority: 99
pid 4565's current scheduling policy: SCHED_OTHER
pid 4565's current scheduling priority: 0
pid 4565's new scheduling policy: SCHED_RR
pid 4565's new scheduling priority: 99
pid 4566's current scheduling policy: SCHED_OTHER
pid 4566's current scheduling priority: 0
pid 4566's new scheduling policy: SCHED_RR
pid 4566's new scheduling priority: 99
pid 4567's current scheduling policy: SCHED_OTHER
pid 4567's current scheduling priority: 0
pid 4567's new scheduling policy: SCHED_RR
pid 4567's new scheduling priority: 99
pid 4568's current scheduling policy: SCHED_OTHER
pid 4568's current scheduling priority: 0
pid 4568's new scheduling policy: SCHED_RR
pid 4568's new scheduling priority: 99
pid 4569's current scheduling policy: SCHED_OTHER
pid 4569's current scheduling priority: 0
pid 4569's new scheduling policy: SCHED_RR
pid 4569's new scheduling priority: 99
pid 4570's current scheduling policy: SCHED_OTHER
pid 4570's current scheduling priority: 0
pid 4570's new scheduling policy: SCHED_RR
pid 4570's new scheduling priority: 99

参考

gettid(2) - Linux manual page
busybox(1): Swiss Army Knife of Embedded - Linux man page

标签:busybox,chrt,SCHED,policy,pid,current,scheduling,TID,new
From: https://www.cnblogs.com/azureology/p/17769259.html

相关文章

  • kernel6.5.7+busybox1.36.1制作一个Mini Linux (没启动起来)
    目录前奏下载linux内核源码并编译下载busybox的源代码制作根文件系统镜像文件安装qemu...有兴趣的同学可参考该文档将其完善...前奏rambo@debian:~$cat/etc/issueDebianGNU/Linux12\n\lrambo@debian:~$free-htotalusedfree......
  • macOS 安装 clang-tidy
    先安装homebrew,网上教程很多,推荐官方教程,此处略过通过brew安装llvmbrewinstallllvm创建软连接,指向homebrew安装的clang-tidymkdir-p/usr/local/bin/ln-s/opt/homebrew/Cellar/llvm/13.0.0_1/bin/clang-tidy/usr/local/bin/clang-tidy注1:推荐创建软连......
  • tiup离线安装tidb6.5.3
    tidb6.5.3规划ip资源规划备注192.168.10.574C/8G/100Gpd、tikv192.168.10.564C/8G/100Gtikv、pd、cdc192.168.10.554C/8G/100Gtidb、tikv192.168.10.544C/8G/100Gpd、tidb192.168.10.534C/8G/100G监控、中控、tidb软件安装1、配置......
  • tidb的regins管理
    ```bash命令及sql查看#tidb热点regins查看select*frominformation_schema.tidb_hot_regionswhereREGION_ID='121930461';select*frominformation_schema.TIKV_REGION_PEERSlimit10;#regins存储位置是否为leaderselect*frominformation_schema.TIKV_REGION_STATUS......
  • MultiDex介绍与使用
    MultiDexClass文件与Dex文件Dex(Dalvik-executable)class文件处理后的产物,专门为安卓上的虚拟机设计的一种压缩格式inJAVA:*.java*.kt=>*.class=>JVMinAndroid:*.java*.kt=>*.class=>(去冗余)*.dex=>DalvikVMorARTVM使用MultiDex的原由当Android应......
  • TiDB恢复部分表的方式方法
    TiDB恢复部分表的方式方法背景今天同事告知误删了部分表.因为是UAT准生产的环境,所以仅有每天晚上11点的备份处理.同时告知昨天的数据也可以.得到认可后进行了TiDB的单表备份恢复.备份的语句注意TiDB是可以增量备份恢复的但是为了快速的恢复和解决背景中的问题.......
  • Androidstudio中 unable to execute Clang-tidy clazy-standalone is not found or ca
    这个问题可能是因为AndroidStudio不支持clazy,但是在设置菜单中仍然提供了这个选项,并且在这种情况下,它似乎被启用了¹。当通过clangd启用clang-tidy时,没有什么需要做的。当通过clangd禁用clang-tidy时,如果启用了clazy,就会出现这个错误¹。要解决这个问题,你可以尝试以下步骤:1.转......
  • webapi 登录接口acctID参数获取SQL
    USEK3DBConfiger20216155555176selectA.FNUMBER,B.FNAME,A.FDATABASENAME,A.FDATACENTERIDFROMT_BAS_DATACENTERASALEFTJOINT_BAS_DATACENTER_LASBONA.FDATACENTERID=B.FDATACENTERIDANDA.FLANGUAGE=B.FLOCALEID FDATACENTERID字段......
  • 执行 go mod tidy 后卡住的解决方案
    内容来自对chatgpt的咨询原因gomodtidy卡住可能有以下几个原因:网络问题:gomodtidy时需要从网络下载依赖,如果网络不稳定或者因为某些原因访问某些资源地址很慢,可能导致此命令延迟或者卡住。可以尝试使用Go的官方代理或其他信赖的代理,例如设置环境变量exportGOPROXY=htt......
  • HTML Tidy 将HTML转换为XHTML的开源工具
    基本信息软件名称:HTMLTidy开发者主页:tidy.sourceforge.net软件大小:112K安装环境:有多平台版本,本站提供MicrosoftWindows95/98/Me/2000/xp平台版本版本:2005年8月由W3C香港分部提供此版本增加了对gb2312编码的支持软件说明我们现在的网站大部分都是HTML的,如果希望将它们标......