title: How does pthread implemented in linux kernel 3.2?
body: <p>all,</p>
  
  <p>The code below comes from "Advanced Programing in Unix Environment", it creates a new thread, and prints the process id and thread id for main and new threads.</p>
  
  <p>In the book, it said that in linux, the output of this code would show that two threads have different
  process ids, because pthread uses lightweight process to emulate thread. But when I ran this code in Ubuntu 12.04, it has kernel 3.2, printed the same pid.</p>
  
  <p>so, does the new linux kernel change the internal implementation of pthread?</p>
  
  <pre><code>#include "apue.h"
  #include &lt;pthread.h&gt;
  
  pthread_t ntid;
  
  void printids(const char *s) {
    pid_t     pid;
    pthread_t tid;
    pid = getpid();
    tid = pthread_self();
    printf("%s pid %u tid %u (0x%x)\n",
           s, (unsigned int)pid, (unsigned int)tid, (unsigned int)tid);
  }
  
  void *thread_fn(void* arg) {
    printids("new thread: ");
    return (void *)0;
  }
  
  int main(void) {
    int err;
    err = pthread_create(&amp;ntid, NULL, thread_fn, NULL);
    if (err != 0)
      err_quit("can't create thread: %s\n", strerror(err));
    printids("main thread: ");
    sleep(1);
    return 0;
  }
  </code></pre>