리눅스 multi core therad 프로그램을 작성할 때 질문입니다.

mjcho86의 이미지

안녕하세요~

처음 글을 남기게 되네요.

다름이 아니라 제목처럼 멀티코어쓰래드 프로그램을 작성하려 하는데요

각 쓰래드별로 cpu 코어 id를 확인하고 싶은데

어떻게 해야 하는지 궁금합니다.

답변부탁드려요~

kerino의 이미지

getcpu를 쓰시면 됩니다~ 써본적은 없어서리 -_- man page 참조하세영~

man getcpu

GETCPU(2) Linux Programmer's Manual GETCPU(2)

NAME
getcpu - determine CPU and NUMA node on which the calling thread is running

SYNOPSIS
#include

int getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache);
.........

mjcho86의 이미지

한번 도전해보겠습니당!