when we write a program, cpu and memory usages are very important to indicate the stability of the program. Once the cpu usage reached 90%, there are some bugs in your program, and you must find the problem. Here is a simply guide to debug with cpu 100%. For example:

void *first_routine (void * args)
{
while()
{
int a = ;
usleep();
} return NULL;
} int main()
{
pthread_t thread_first, thread_second;
pthread_create(&thread_first, NULL, &first_routine, NULL); while()
{
sleep();
}
return ;
}

then complile it : gcc debug.c -o debug -lpthread , and run it .

iii) use top tool find the bug thread,  top -p $pid -H

iv) use pstack : pstack $tid(bug thread), to look the stack of the bug thread. but pstack can't see the paraments. if you still can't determine the bug line, user gcore to get the program core.  (gcore $pid)

v)  gdb -c  $core.file  ./exe , and the use  command  bt(back trace), then use the paraments to determine the bug code.

how to debug thread cpu 100%的更多相关文章

  1. 解决new Thread().Start导致高并发CPU 100%的问题

    背景 之前接手一个项目的时候,发现到处是 new Thread(()=>{ //do something }).Start(); 这么做的目的,无非是为了减少页面等待时间提高用户体验,把一些浪费 ...

  2. [Java] CPU 100% 原因查找解决

    CPU 100%肯定是出现死锁,这个时候观察内存还是够用的,但是CPU一直100%,以下几步解决: 1. 找到进程消耗cpu最大的 $top top - :: up days, :, user, lo ...

  3. Linux系统cpu 100%修复案例

    Linux系统cpu 100%修复案例 ​阿里云技术支持团队:完颜镇江 案例背景: Linux主机连续三天CPU% 处理思路: 1.  登录服务器查看/var/log/messages+/var/lo ...

  4. 系统运行缓慢,CPU 100%,以及Full GC次数过多问题的排查思路

    前言 处理过线上问题的同学基本上都会遇到系统突然运行缓慢,CPU 100%,以及Full GC次数过多的问题.当然,这些问题的最终导致的直观现象就是系统运行缓慢,并且有大量的报警. 本文主要针对系统运 ...

  5. Linux(2)---记录一次线上服务 CPU 100%的排查过程

    Linux(2)---记录一次线上服务 CPU 100%的排查过程 当时产生CPU飙升接近100%的原因是因为项目中的websocket时时断开又重连导致CPU飙升接近100% .如何排查的呢 是通过 ...

  6. JDK8的ConcurrentHashMap也会造成CPU 100%

    转载:不止 JDK7 的 HashMap ,JDK8 的 ConcurrentHashMap 也会造成 CPU 100%?原因与解决~ 现象 大家可能都听过JDK7中的HashMap在多线程环境下可能 ...

  7. Java死锁排查和Java CPU 100% 排查的步骤整理

    ================================================= 人工智能教程.零基础!通俗易懂!风趣幽默!大家可以看看是否对自己有帮助! 点击查看高清无码教程 == ...

  8. 线上服务 CPU 100%?一键定位 so easy!

      转自:  https://my.oschina.net/leejun2005/blog/1524687   摘要: 本文主要针对 Java 服务而言 0.背景 经常做后端服务开发的同学,或多或少都 ...

  9. 一文学会Java死锁和CPU 100% 问题的排查技巧

    做一个积极的人 编码.改bug.提升自己 我有一个乐园,面向编程,春暖花开 工欲善其事,必先利其器 00 本文简介 作为一名搞技术的程序猿或者是攻城狮,想必你应该是对下面这两个问题有所了解,说不定你在 ...

随机推荐

  1. IP, TCP, and HTTP--reference

    IP, TCP, and HTTP Issue #10 Syncing Data, March 2014 By Daniel Eggert When an app communicates with ...

  2. LeetCode44 Wildcard Matching

    题目: Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single charact ...

  3. WPF 之 窗口间传参数

    有如下几种方式: 1) 声明个全局变量,就是App.xaml里面声明:在所有窗体里面都可以引用 Application.Current.Properties["ArgumentName&qu ...

  4. Xamarin自学教程(Android)之一

    废话少说,我们直接开始吧.有兴趣的就一起,我慢慢写,咱们一起慢慢学.希望两个月内能基本完成基于Xamarin的Android开发内容. 还是一样,先来安装开发环境吧.跟着做就行了. 首先,我们到微软的 ...

  5. 通过pinyin4j将汉字转换为全拼 和 拼音首字母

    /** * 汉字转换为拼音 包含多音字,包含生母zh,ch,sh的 */ public void toPinYinAll(){ String initials = "zh,ch,sh&quo ...

  6. web开发人员须知的web缓存知识–将数据缓存到浏览器端Net实现

    现实中,服务器在向浏览器发送的数据中,一部分数据是不经常更新的,如果能将这部分数据缓存到浏览器端,将会大大降低传输的数据,提高应用的性能.通过Expires策略,可以使用HTTP 协议定义的缓存机制将 ...

  7. UIButton的简单操作和实际应用

    不能使用点语法创建button的文本和颜色,因为button具有多种状态   //这里创建一个圆角矩形的按钮UIButton *button1 = [UIButton buttonWithType:U ...

  8. VS2013 支持python和nodejs

    一.在VS2013中,安装python的支持 1. http://pytools.codeplex.com/下载插件 2. https://www.python.org/download/下载Pyth ...

  9. Oracle基础 数据泵导出/导入Expdp/impdp(转)

    一.EXPDP和IMPDP使用说明 Oracle Database 10g引入了最新的数据泵(Data Dump)技术,数据泵导出导入(EXPDP和IMPDP)的作用 1)实现逻辑备份和逻辑恢复. 2 ...

  10. 未能正确加载“radlangsvc.package,radlangsvc.vs,version=10.0.0,culture=neutra

    1: 参考 http://blog.csdn.net/woaizhoulichao1/article/details/6911809 2: 开 始-->所有程序 -->Mircosoft  ...