摘要 |
Disclosed is a computer program that, when run, can determine the resource usage (for example, processor time) of tasks (or job, process, subroutine). The determination is performed on behalf of the user application such that is does not require calls to the Operating System (OS). When a task is started, a privileged instruction (i.e. one unavailable to the user application) stores the value of a CPU timer. When the user application wishes to know the amount of execution time, it executes a non-privileged instruction which calculates the elapsed time and reports it in a single uninterruptible operation. This is achieved by subtracting the start time from the end time such that the difference is equivalent to the execution time. The invention can also be used to determine the running time of a task that is switched in and out of execution. For each time slice that the task is running, the time taken is added into an accumulation value to give the time taken so far. |