![]() In Linux, the number of clocks is reduced, but anyway, you can most times get some idea of that. CLOCK_REALTIME_PRECISE Increments as a wall clock should.CLOCK_THREAD_CPUTIME_ID Returns the execution time of the calling thread.CLOCK_PROCESS_CPUTIME_ID Returns the execution time of the calling process.CLOCK_PROF Increments when the CPU is running in user or kernel mode.CLOCK_VIRTUAL Increments only when the CPU is running in user mode on behalf of the calling process.You'll get a coarse and non-precise value from the difference between clocks. If you compare times by using the different clock_gettime clocks available in your system, you can estimate the amount of cpu time that your process has consumed on its behalf and how much time the system has been doing otherwise. you have a simple means of checking an estimate. Which ones, or how they change into a process (or thread) context switch is not normally available, but by looking at the kernel source code.īut. Normally, the kernel maintains counters to know how many interrupts of type X have been counted and you can use the difference in counter values to know how many interrupts of type X have occurred since then. Trying to know how many times your process has been interrupted by something between to program points is a huge task, as there are many devices doing that, and you cannot, in general, assume there's been a context switch at any one of those interrupts. What is true, is that you will be scheduled when you first start the chrono, and then when you try to see what has happened. Probably you can access (well, I assume you have administrator rights if you plan a so challenging problem) a kernel variable registering the number of context switches it does, and so, compute the number of times your process has been scheduled-out from the cpu since some time in the past. ![]() There's a difficult challenge on that, as the timer interrupt is, by definition asynchronous, and the kernel can decide to pre-empt your process on any timer interrupt.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |