프로세스별 쓰레드 ID에 대하여
멀티 프로세스안에
멀티 쓰레드가 돌아가는 복잡한 프로그래밍중인데......
쓰레드 id에 대하여 의문점이 생겨서 글을 올립니다.
3개의 프로세스에서 10개의 쓰레드를 돌려 총 30개의 쓰레드를 돌리는데
다음과 같이 쓰레드 아이디가 동일한 현상을 보았습니다.
쓰레드가 프로세스 별로 저렇게 동일한 id를 계속 만들수 있는건가요???
만들어 졌다고 하면 같은 id를 지니고 있더라도 별개의 쓰레드가 되는건가요???
thread id :3074243392 run*********************
thread id :3074243392 run*********************
thread id :3074243392 run*********************
thread id :3065850688 run*********************
thread id :3065850688 run*********************
thread id :3065850688 run*********************
thread id :3057457984 run*********************
thread id :3057457984 run*********************
thread id :3057457984 run*********************
thread id :3049065280 run*********************
thread id :3049065280 run*********************
thread id :3049065280 run*********************
thread id :3040672576 run*********************
thread id :3040672576 run*********************
thread id :3040672576 run*********************
thread id :3032279872 run*********************
thread id :3032279872 run*********************
thread id :3032279872 run*********************
thread id :3023887168 run*********************
thread id :3023887168 run*********************
thread id :3023887168 run*********************
thread id :3015494464 run*********************
thread id :3015494464 run*********************
thread id :3015494464 run*********************
thread id :3007101760 run*********************
thread id :3007101760 run*********************
thread id :3007101760 run*********************
thread id :2998709056 run*********************
thread id :2998709056 run*********************
thread id :2998709056 run*********************
저 쓰레드 아이디가 다른 언어에서 제공해주는 래퍼
저 쓰레드 아이디가 다른 언어에서 제공해주는 래퍼 라이브러리에서 제공해주는 id인지 native id인지 모르기 때문에
Linux native thread를 기준으로 설명해드리겠습니다.
From man page pthreads(7)
프로세스 내부에서 '유일'하다라고 언급되어있습니다
(Each of the threads in a process has a unique thread identifier)
(Thread IDs are guaranteed to be unique only within a process.)
저에게는 파일 디스크립터하고 동일한 개념이라고 생각되는데요.
리눅스/유닉스 계열 쓴따는 가정하에, man page 찾아보는걸 습관화 하시길 바랍니다.
댓글 달기