Well my understanding on thread's local storage is somewhat like this, please correct me if I am wrong. Isn't the local storage of thread done on thread's local stack (why we need TLS and what does it exactly contain), which is seperate for each thread. As far as the linux kernel is concerned, I think it does not differentiate betwen a process and thread, even threads are also handled in a same ways as the process is done in kernel. When we start a new thread using clone system call, kernel on its side perform the same activity which it do for any process forking, except that it shares few of the resources among parent and child process (in our case, thread being invoked) in the case of clone, as those are seen as two threads on application side, but on kernel side those are two seperate entities of execution. When we make clone() system call, kernel creates a new process descriptor (task_struct) and copies the common enteries from parent's task_struct, later it initialize few of the enteries in child process (in our case thread being invoked) to their default value and finally it copies few of the enteries depending upon whih CLONE flags have been in set by user while making clone() system call, which actually shares the resources between two threads. Here the new stack is allocated to new thread, where new thread keeps its local storage during its life. Whats the role of TLS exactly in all this. regards, -Gaurav On 6/21/05, Mulyadi Santosa <mulyadi.santosa@xxxxxxxxx> wrote: > Dear Thomas....Christophe....everyone.... > > Thank you for your time and effort to explain these to me..... > > I will observe the details again in a week or two... right now, my best > conclusion is, LDT is created so each thread won't cross "the police > line" and access the other thread's storage. This is proven by the > result of strace that shows, during each clone syscall, a new base > address and limit are passed into kernel space in order to create new > LDT entry > > Another raw conclusion I got ... from gcc -S result executed on the my > pthread progran, I did see an assembly instruction (movl IIRC) that > retrieves a content of memory address with the following format > %gs:<some offset>. So I guess, gs here is indeed used to point on the > related segment for the running thread > > regards > > Mulyadi > > > -- > Kernelnewbies: Help each other learn about the Linux kernel. > Archive: http://mail.nl.linux.org/kernelnewbies/ > FAQ: http://kernelnewbies.org/faq/ > > -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/