• 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;
      }
    }
    
  • 相关阅读:
    iOS设计模式-工厂方法
    iOS设计模式-原型模式
    (转)iOS 屏幕适配
    iOS设计模式-MVC
    转 常用第三方库
    学习资料收集
    xcode 插件
    CocoaPods安装和使用
    iOS 友盟统计的bug分析
    HTML——表格
  • 原文地址:https://www.cnblogs.com/chenzhengxi/p/14657647.html
Copyright © 2020-2023  润新知