static void
ThreadedCalculateProcessCreationTimestamp(void *aClosure)
{
  PRTime now = PR_Now();
  gProcessCreationTimestamp = 0;
  long hz = sysconf(_SC_CLK_TCK);
  if (!hz)
    return;

  char thread_stat[40];
  sprintf(thread_stat, "/proc/self/task/%d/stat", (pid_t) syscall(__NR_gettid));
  
  PRTime interval = (JiffiesSinceBoot(thread_stat) - JiffiesSinceBoot("/proc/self/stat")) * PR_USEC_PER_SEC / hz;;
  gProcessCreationTimestamp = now - interval;
}
Esempio n. 2
0
static void
ComputeProcessUptimeThread(void *aTime)
{
  uint64_t *uptime = static_cast<uint64_t *>(aTime);
  long hz = sysconf(_SC_CLK_TCK);

  *uptime = 0;

  if (!hz)
    return;

  char threadStat[40];
  sprintf(threadStat, "/proc/self/task/%d/stat", (pid_t) syscall(__NR_gettid));

  uint64_t threadJiffies = JiffiesSinceBoot(threadStat);
  uint64_t selfJiffies = JiffiesSinceBoot("/proc/self/stat");

  if (!threadJiffies || !selfJiffies)
    return;

  *uptime = ((threadJiffies - selfJiffies) * kNsPerSec) / hz;
}