in reply to Re: cpu time within a thread
in thread cpu time within a thread

Thanks. I understand that threads won't help (and will likely slow) clock time on a single processor, but that they are useful for I/O. The question is about cpu time.
Theoretically, in this toy example, the cpu should spend roughly the same amount of time within each thread (no?), no matter how many threads are running.
I'm wondering if there is a way to measure the cpu time within each thread.
Thanks again.

Replies are listed 'Best First'.
Re^3: cpu time within a thread
by BrowserUk (Patriarch) on Jul 28, 2004 at 18:52 UTC

    Not that I am aware of under Win32.

    I seem to recall somebody mentioning that under some versions/configurations of *nix, threads were listed in top as separate entities much like processes, but I also seem to recall that this was being superceded by a 'rolled up' view of each process. Sorry, I can't remember where I read this, it could be a figment of my imagination.

    This isn't something that can be easily done outside of the kernel. Any timing based upon the system clock simply won't account for the time when a thread is 'swapped out'.

    The only mechanism by which this might be possible is if there is an interface to the scheduler and I do not know of any such.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon
      "Any timing based upon the system clock simply won't account for the time when a thread is 'swapped out'"
      That's what I figured. Thanks!