How to compute the amount of time a thread has been running on cpu

Amit kumar <[email protected]>
Newsgroups gmane.os.freebsd.architechture
Message-ID <DM4PR11MB55194EC3EA40B394DA8EF4E3DCFF9@DM4PR11MB5519.namprd11.prod.outlook.com>
I am trying to figure out how long a thread(sitting on a particular CPU's real-time RUNQ) has been running on the CPU, (might help if I can collect the runtime stats of the tread across the CPUs in the case it did run on other CPUs too).

I came across td_runtime and ts_runtime.

  ts_slptime = 18008,
  ts_runtime = 414196,

  td_slptick = 0,
  td_blktick = 0,
  td_incruntime = 36984047370,
  td_runtime = 55246215882,
  td_lastcpu = 0,
  td_oncpu = -1,

looking at the code it seems ts_runtime is a decayed sum, but I dint find the same for td_runtime.

Can someone help me find out how long this thread has been running and which paramere is more reliable?

Another question
I see db_show_thread, converts ticks to ms, using the calculation listed below, is this correct or just an approximation?

delta = (u_int)ticks - (u_int)td->td_swinvoltick;
db_printf(" last involuntary switch: %d ms ago\n",
   1000 * delta / hz);


-AK
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.