os::current_process_id()
- カレントプロセスが実行されているプロセッサのプロセッサIDを取得する
//Linux版(jdk7/hotspot/src/os/linux/vm/os_linux.cpp) int os::current_process_id() { // Under the old linux thread library, linux gives each thread // its own process id. Because of this each thread will return // a different pid if this method were to return the result // of getpid(2). Linux provides no api that returns the pid // of the launcher thread for the vm. This implementation // returns a unique pid, the pid of the launcher thread // that starts the vm 'process'. // Under the NPTL, getpid() returns the same pid as the // launcher thread rather than a unique pid per thread. // Use gettid() if you want the old pre NPTL behaviour. // if you are looking for the result of a call to getpid() that // returns a unique pid for the calling thread, then look at the // OSThread::thread_id() method in osThread_linux.hpp file return (int)(_initial_pid ? _initial_pid : getpid()); }