您当前的位置: 首页 >  linux
  • 2浏览

    0关注

    880博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Linux 线程CPU占用率过高定位分析

CodeAllen嵌入式编程 发布时间:2020-07-21 23:01:55 ,浏览量:2

在Linux开发中经常会与多线程打交道,所以多线程开发与调试就很重要

下边说下Linux调试过程中CPU占用率过高的情况怎么调试

CPU占用过高,模拟CPU占用过高的情况

先上一段代码:

#include 
#include 
#include 

int main(int argc, char **argv) {

    std::vector test_threads;
    for(int i = 0; i < 9; i++){
      test_threads.push_back(std::thread([]{
    while(1){
      std::this_thread::sleep_for(std::chrono::milliseconds(500));
    }
      }));
    }
    test_threads.push_back(std::thread([]{
      while(1){
      std::cout            
关注
打赏
1665938897
查看更多评论
0.0415s