zoukankan      html  css  js  c++  java
  • arm平台下使用cpulimit

    为了限制系统内各模块的cpu占用,用到cpulimit工具,如下限制test的cpu占用110%,最大cpu占用=cpu核个数*100%。

    ./cpulimit -e test -l 110
    

    在arm平台下代码存在bug,basename函数会返回无效值,我做了如下修改

    int find_process_by_name(const char *process_name)
    {
      //pid of the target process
      pid_t pid = -1;
      //process iterator
      struct process_iterator it;
      struct process proc;
      struct process_filter filter;
      filter.pid = 0;
      filter.include_children = 0;
      init_process_iterator(&it, &filter);
      while (get_next_process(&it, &proc) != -1)
      {
        int diff_len = strlen(proc.command) - strlen(process_name);
        if (diff_len >= 0)
        {
          char *guess_name = proc.command + diff_len;
          if (strncmp(guess_name, process_name, strlen(process_name)) == 0 && kill(pid, SIGCONT) == 0)
          {
            pid = proc.pid;
            break;
          }
        }
      }
      if (close_process_iterator(&it) != 0)
        exit(1);
      if (pid >= 0)
      {
        //ok, the process was found
        return pid;
      }
      else
      {
        //process not found
        return 0;
      }
    }
    
  • 相关阅读:
    爬虫杂七杂八
    pycharm使用技巧
    python杂七杂八
    mysql杂七杂八
    mysql常见函数总结:
    CF1030F Putting Boxes Together
    AT2688 [ARC080C] Young Maids
    P5280 [ZJOI2019]线段树
    雨的味道
    P2572 [SCOI2010]序列操作
  • 原文地址:https://www.cnblogs.com/chenzhengxi/p/14657647.html
Copyright © 2011-2022 走看看