Summary:
Use the newly introduced getOSThreadID() function to get a thread ID for
determining thread scheduling information on Linux.
Reviewed By: yfeldblum
Differential Revision:
D5173596
fbshipit-source-id:
3e6fa352c3774986b0ac1f93bd6c7e4a29e08471
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/utsname.h>
#endif
#include <sys/utsname.h>
#endif
#include <folly/Conv.h>
#include <folly/ScopeGuard.h>
#include <folly/Conv.h>
#include <folly/ScopeGuard.h>
-#include <folly/portability/SysSyscall.h>
+#include <folly/ThreadId.h>
#include <folly/portability/Unistd.h>
#include <folly/portability/Unistd.h>
-#include <folly/portability/Windows.h>
#include <glog/logging.h>
#include <glog/logging.h>
-#ifdef _MSC_VER
-static pid_t gettid() {
- return pid_t(GetCurrentThreadId());
-}
-#else
-/**
- * glibc doesn't provide gettid(), so define it ourselves.
- */
-static pid_t gettid() {
- return syscall(FOLLY_SYS_gettid);
-}
-#endif
-
static int getLinuxVersion(StringPiece release) {
auto dot1 = release.find('.');
if (dot1 == StringPiece::npos) {
static int getLinuxVersion(StringPiece release) {
auto dot1 = release.find('.');
if (dot1 == StringPiece::npos) {
timeStart_ = system_clock::now();
// Remember how long this process has spent waiting to be scheduled
timeStart_ = system_clock::now();
// Remember how long this process has spent waiting to be scheduled
+ tid_ = getOSThreadID();
timeWaiting_ = getTimeWaitingMS(tid_);
// In case it took a while to read the schedstat info,
timeWaiting_ = getTimeWaitingMS(tid_);
// In case it took a while to read the schedstat info,