< prev index next >
agent/src/os/linux/libproc.h
Print this page
rev 8364 : 8078513: [linux] Clean up code relevant to LinuxThreads implementation
Reviewed-by: dholmes, sla, coleenp
@@ -41,30 +41,24 @@
0. This is very minimal subset of Solaris libproc just enough for current application.
Please note that the bulk of the functionality is from proc_service interface. This
adds Pgrab__ and some missing stuff. We hide the difference b/w live process and core
file by this interface.
-1. pthread_id unique in both NPTL & LinuxThreads. We store this in
-OSThread::_pthread_id in JVM code.
+1. For historical reasons there are both pthread id (stored in OSThread::_pthread_id)
+and kernel thread id (gettid() syscall, stored in OSThread::_thread_id) kept in OSThread.
+Both are unique. We use OSThread::_thread_id as unique identifier.
-2. All threads see the same pid when they call getpid() under NPTL.
-Threads receive different pid under LinuxThreads. We used to save the result of
-::getpid() call in OSThread::_thread_id. This way uniqueness of OSThread::_thread_id
-was lost under NPTL. Now, we store the result of ::gettid() call in
-OSThread::_thread_id. Because gettid returns actual pid of thread (lwp id), this is
-unique again. We therefore use OSThread::_thread_id as unique identifier.
-
-3. There is a unique LWP id under both thread libraries. libthread_db maps pthread_id
+2. There is a unique LWP id under both thread libraries. libthread_db maps pthread_id
to its underlying lwp_id under both the thread libraries. thread_info.lwp_id stores
lwp_id of the thread. The lwp id is nothing but the actual pid of clone'd processes. But
unfortunately libthread_db does not work very well for core dumps. So, we get pthread_id
only for processes. For core dumps, we don't use libthread_db at all (like gdb).
-4. ptrace operates on this LWP id under both the thread libraries. When we say 'pid' for
+3. ptrace operates on this LWP id under both the thread libraries. When we say 'pid' for
ptrace call, we refer to lwp_id of the thread.
-5. for core file, we parse ELF files and read data from them. For processes we use
+4. for core file, we parse ELF files and read data from them. For processes we use
combination of ptrace and /proc calls.
*************************************************************************************/
< prev index next >