Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Aug 2021 09:43:14 +0000
From:      Amit kumar <akamit91@hotmail.com>
To:        "freebsd-arch@freebsd.org" <freebsd-arch@freebsd.org>
Subject:   How to compute the amount of time a thread has been running on cpu
Message-ID:  <DM4PR11MB55194EC3EA40B394DA8EF4E3DCFF9@DM4PR11MB5519.namprd11.prod.outlook.com>

next in thread | raw e-mail | index | archive | help
--_000_DM4PR11MB55194EC3EA40B394DA8EF4E3DCFF9DM4PR11MB5519namp_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I am trying to figure out how long a thread(sitting on a particular CPU's r=
eal-time RUNQ) has been running on the CPU, (might help if I can collect th=
e runtime stats of the tread across the CPUs in the case it did run on othe=
r CPUs too).

I came across td_runtime and ts_runtime.

  ts_slptime =3D 18008,
  ts_runtime =3D 414196,

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

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

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

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

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


-AK

--_000_DM4PR11MB55194EC3EA40B394DA8EF4E3DCFF9DM4PR11MB5519namp_--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?DM4PR11MB55194EC3EA40B394DA8EF4E3DCFF9>