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,怎么看. ...
随机推荐
- Centos 下安装 文泉驿 字体 Odoo
刚装完centos下的odoo的字体 文泉驿 ,一万头草泥马呼啸而过.....劝君如非必要,千万别再centos下折腾odoo..... 正题,文泉驿官网 只提供 deb包和源码包的字体安装 ,想在c ...
- ArcGIS AddIN开发异常之--“ValidateAddInXMLTask”任务意外失败
ArcGIS AddIN开发时,产生如下异常错误 2 “ValidateAddInXMLTask”任务意外失败.System.NullReferenceException: 未将对象引用设置到对象的 ...
- Python 基础 - 对文本的处理
Python 对文本文件的处理. 对文本操作之前,必须要先open 这个文件,open完成之后需要close . # -*- coding: utf-8 -*- f=open('test.txt',' ...
- mysql语句中有引号的问题解决方案
在mysql的查询.修改.插入.删除的sql语句里有引号如何处理? 例如: <? $name = "my name is xcxc"; $people = "i'm ...
- (转)实例分析:MySQL优化经验
[IT专家网独家]同时在线访问量继续增大,对于1G内存的服务器明显感觉到吃力,严重时甚至每天都会死机,或者时不时的服务器卡一下,这个问题曾经困扰了我半个多月.MySQL使用是很具伸缩性的算法,因此你通 ...
- coolpro2 剪切并淡出
1.先将音乐暂停或者停止. 2.选择需要淡出的一段音乐 3.选择效果--波形振幅--渐变 4.选择Fade-out,确定
- 数据库---MySQL练习题及答案
一. 设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表( ...
- 安装SSD固态硬盘
满足三个要求:开启AHCI."4K对齐".SSD初始化. 1. 开启AHCI模式 重启,进入bios,高级模式,SATA模式选择,选择AHCI. 2. 4K对齐 第3步,在分区的时 ...
- iOS 数组内中英文混合排序
NSInteger sortObjects(id obj1, id obj2,void *context) { NSMutableString * str1 = [[NSMutableString a ...
- LeetCode Graph Valid Tree
原题链接在这里:https://leetcode.com/problems/graph-valid-tree/ 题目: Given n nodes labeled from 0 to n - 1 an ...