Skip to content

[임민채] 프로젝트 소개 #188

@minchae

Description

@minchae

Project

프로젝트명

multithread 상에서 perf

분야별 및 정의

multithread 프로그래밍에서 perf를 이용하여 성능개선

사용언어

c++

폴더 구조

.
├── Documentation
├── arch
│   ├── alpha
│   ├── arm
│   │   ├── annotate
│   │   ├── include
│   │   ├── tests
│   │   └── util
│   ├── arm64
│   │   ├── annotate
│   │   ├── include
│   │   ├── tests
│   │   └── util
│   ├── mips
│   ├── parisc
│   ├── powerpc
│   │   ├── annotate
│   │   ├── include
│   │   ├── tests
│   │   └── util
│   ├── s390
│   │   ├── annotate
│   │   ├── include
│   │   └── util
│   ├── sh
│   │   ├── include
│   │   └── util
│   ├── sparc
│   │   ├── include
│   │   └── util
│   ├── x86
│   │   ├── annotate
│   │   ├── entry
│   │   │   └── syscalls
│   │   ├── include
│   │   ├── tests
│   │   └── util
│   └── xtensa
│       ├── include
│       └── util
├── bench
├── jvmti
├── pmu-events
│   └── arch
│       ├── powerpc
│       │   ├── power8
│       │   └── power9
│       └── x86
│           ├── bonnell
│           ├── broadwell
│           ├── broadwellde
│           ├── broadwellx
│           ├── goldmont
│           ├── haswell
│           ├── haswellx
│           ├── ivybridge
│           ├── ivytown
│           ├── jaketown
│           ├── knightslanding
│           ├── nehalemep
│           ├── nehalemex
│           ├── sandybridge
│           ├── silvermont
│           ├── skylake
│           ├── skylakex
│           ├── westmereep-dp
│           ├── westmereep-sp
│           └── westmereex
├── python
├── scripts
│   ├── perl
│   │   ├── Perf-Trace-Util
│   │   │   └── lib
│   │   │       └── Perf
│   │   │           └── Trace
│   │   └── bin
│   └── python
│       ├── Perf-Trace-Util
│       │   └── lib
│       │       └── Perf
│       │           └── Trace
│       └── bin
├── tests
│   ├── attr
│   └── shell
│       └── lib
├── trace
│   ├── beauty
│   └── strace
│       └── groups
├── ui
│   ├── browsers
│   ├── gtk
│   ├── stdio
│   └── tui
└── util
    ├── c++
    ├── include
    │   ├── asm
    │   └── linux
    ├── intel-pt-decoder
    ├── libunwind
    └── scripting-engines

103 directories

Example

perf 적용

image

image

image

실제코드

#include<stdio.h>
#include<pthread.h>

#define NUM_THREAD 2
#define NUM_INCREASE 5


int cnt_global =0;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

void* ThreadFunc(void* arg){
	long cnt_local =0;
	for(int i=0;i<NUM_INCREASE;i++){
		pthread_mutex_lock(&mutex);
		cnt_global++;
		pthread_mutex_unlock(&mutex);
		cnt_local++;
	}
	return (void*)cnt_local;
}


int main(void){
	pthread_t threads[NUM_THREAD];
	for(int i=0;i<NUM_THREAD;i++){
		if(pthread_create(&threads[i],0,ThreadFunc,NULL)<0){
			printf("pthread_create error!\n");
			return 0;
		}
	}
	
	long ret;
	for(int i=0;i<NUM_THREAD;i++){
		pthread_join(threads[i],(void**)&ret);
		printf("thread %ld, local count: %ld\n",threads[i],ret);
	}
	printf("global count: %d\n",cnt_global);
	return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions