create thread的时候发生core dump
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
#define THREAD_COUNT 12 void show_thread_policy(int threadno){
int policy;
struct sched_param param;
pthread_getschedparam(pthread_self(), &policy, ¶m);
switch(policy){
case SCHED_OTHER:
printf("SCHED_OTHER %d\n", threadno);
break;
case SCHED_RR:
printf("SCHED_RR %d\n", threadno);
break;
case SCHED_FIFO:
printf("SCHED_FIFO %d\n", threadno);
break;
default:
printf("UNKNOWN\n");
}
} void *thread(void *arg){
int i,j;
long threadno = (long)arg;
printf("thread %d start \n", threadno);
printf("thread ------------------------------0\n");
sleep();
printf("---------1---------------\n");
show_thread_policy(threadno);
printf("---------2---------------\n");
for(int i=;i<;i++){
printf("---------3---------------\n");
for(j=;j<;j++){ } printf("thread %d\n", threadno);
} printf("thread %d exit\n", threadno);
return NULL;
} int main(int argc, char *argv[]){
long i;
pthread_attr_t attr[THREAD_COUNT];
pthread_t pth[THREAD_COUNT];
struct sched_param param;
for(i=;i<THREAD_COUNT;++i){
pthread_attr_init(&attr[i]);
for(i=;i<THREAD_COUNT/;++i){
param.sched_priority = ;
pthread_attr_setschedpolicy(&attr[i], SCHED_FIFO);
pthread_attr_setschedparam(&attr[i], ¶m);
pthread_attr_setinheritsched(&attr[i], PTHREAD_EXPLICIT_SCHED);
} for(i=THREAD_COUNT/;i<THREAD_COUNT;++i){
param.sched_priority = ;
pthread_attr_setschedpolicy(&attr[i], SCHED_FIFO);
pthread_attr_setschedparam(&attr[i], ¶m);
pthread_attr_setinheritsched(&attr[i], PTHREAD_EXPLICIT_SCHED);
} for(i=;i<THREAD_COUNT;++i){
pthread_create(&pth[i], &attr[i], thread, (void *)i);
printf("--------------------create thread %d------------\n", i);
} for(i=;i<THREAD_COUNT;++i){
pthread_join(pth[i], NULL);
} for(i=;i<THREAD_COUNT;++i){
pthread_attr_destroy(&attr[i]);
} return ;
}
}
编译之后执行的结果如下:
[root@Alston C++]# ./thread_2.exe
thread 0 start
thread ------------------------------0
--------------------create thread 0------------
--------------------create thread 1------------
--------------------create thread 2------------
--------------------create thread 3------------
Segmentation fault (core dumped)
目前还没调查出来原因。
create thread的时候发生core dump的更多相关文章
- linux core dump 文件 gdb分析
core dump又叫核心转储, 当程序运行过程中发生异常, 程序异常退出时, 由操作系统把程序当前的内存状况存储在一个core文件中, 叫core dump. (linux中如果内存越界会收到SIG ...
- core dump gdb调试
core dump又叫核心转储, 当程序运行过程中发生异常, 程序异常退出时, 由操作系统把程序当前的内存状况存储在一个core文件中, 叫core dump. (linux中如果内存越界会收到SIG ...
- Linux Core Dump
当程序运行的过程中异常终止或崩溃,操作系统会将程序当时的内存状态记录下来,保存在一个文件中,这种行为就叫做Core Dump(中文有的翻译成“核心转储”).我们可以认为 core dump 是“内存快 ...
- 【转】段错误调试神器 - Core Dump详解
from:http://www.embeddedlinux.org.cn/html/jishuzixun/201307/08-2594.html 段错误调试神器 - Core Dump详解 来源:互联 ...
- Segment fault及LINUX core dump详解 (zz)
C 程序在进行中发生segment fault(core dump)错误,通常与内存操作不当有关,主要有以下几种情况: (1)数组越界. (2)修改了只读内存. (3)scanf("%d&q ...
- 【转】 Linux Core Dump 介绍
=============================================================== Linux core dump的祥细介绍和使用 =========== ...
- 段错误调试神器 - Core Dump详解
一.前言: 有的程序可以通过编译, 但在运行时会出现Segment fault(段错误). 这通常都是指针错误引起的. 但这不像编译错误一样会提示到文件某一行, 而是没有任何信息, 使得我们的调试变得 ...
- Linux Core Dump【转】
转自:http://www.cnblogs.com/hazir/p/linxu_core_dump.html 当程序运行的过程中异常终止或崩溃,操作系统会将程序当时的内存状态记录下来,保存在一个文件中 ...
- linux下core dump
1.前言 一直在从事linux下后台开发,经常与core文件打交道.还记得刚开始从事linux下开发时,程序突然崩溃了,也没有任何日志.我不知所措,同事叫我看看core,我却问什么是core,怎么看. ...
随机推荐
- 30.编写一个Shape类,具有属性:周长和面积; 定义其子类三角形和矩形,分别具有求周长的方法。 定义主类E,在其main方法中创建三角形和矩形类的对象, 并赋给Shape类的对象a、b,使用对象a、b来测试其特性。
package zuoye8; public abstract class Shape { private double zhouchang ; private double mianji ; pub ...
- Centos 下安装 文泉驿 字体 Odoo
刚装完centos下的odoo的字体 文泉驿 ,一万头草泥马呼啸而过.....劝君如非必要,千万别再centos下折腾odoo..... 正题,文泉驿官网 只提供 deb包和源码包的字体安装 ,想在c ...
- Careercup | Chapter 8
8.2 Imagine you have a call center with three levels of employees: respondent, manager, and director ...
- A trip through the Graphics Pipeline 2011_10_Geometry Shaders
Welcome back. Last time, we dove into bottom end of the pixel pipeline. This time, we’ll switch ...
- js == 判断
根据阮一峰介绍的算法文章分12部分可判断: 如果x不是正常值(比如抛出一个错误),中断执行. 如果y不是正常值,中断执行. 如果Type(x)与Type(y)相同,执行严格相等运算x === y. 如 ...
- Java中的virtual method
今天看jcvm的标准的 时候,看到有一个virtual method,感觉很疑惑,以前看Java的时候并没有发现有这类方法. 百度.Google了一下,才发现,Java中普通方法就是virtual m ...
- Android实现推送方式解决方案
当我们开发需要和服务器交互的应用程序时,基本上都需要获取服务器端的数据,比如<地震应急通>就需要及时获取服务器上最新的地震信息. 要获取服务器上不定时更新的信息,一般来说有两种方法: 第一 ...
- yii2.0 网址重写
- JavasSript实现秒转换为“天时分秒”控件和TDD测试方法应用
背景 时间累计值,在顶层一般以秒为计算单位, 所以到页面上如果直接显示xx秒, 如果秒的值很大, 则用户得不到直观的感受, 到底有多长时间, 在日长生活中, 人们以天 时 分 秒为单位来记录时间累计值 ...
- dubbo源码分析1-reference bean创建
dubbo源码分析1-reference bean创建 dubbo源码分析2-reference bean发起服务方法调用 dubbo源码分析3-service bean的创建与发布 dubbo源码分 ...