프로세스별 쓰레드 ID에 대하여

jang5497의 이미지

멀티 프로세스안에
멀티 쓰레드가 돌아가는 복잡한 프로그래밍중인데......

쓰레드 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*********************

twinwings의 이미지

저 쓰레드 아이디가 다른 언어에서 제공해주는 래퍼 라이브러리에서 제공해주는 id인지 native id인지 모르기 때문에

Linux native thread를 기준으로 설명해드리겠습니다.

From man page pthreads(7)

   Thread IDs
       Each of the threads in a process  has  a  unique  thread  identifier  (stored  in  the  type
       pthread_t).   This  identifier  is returned to the caller of pthread_create(3), and a thread
       can obtain its own thread identifier using pthread_self(3).  Thread IDs are guaranteed to be
       unique  only within a process.  A thread ID may be reused after a terminated thread has been
       joined, or a detached thread has terminated.  In all pthreads functions that accept a thread
       ID as an argument, that ID by definition refers to a thread in the same process as the call‐
       er.

프로세스 내부에서 '유일'하다라고 언급되어있습니다
(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 찾아보는걸 습관화 하시길 바랍니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.