Home |
RTKernel-32 Programming Manual Function CPUMonitorStart |
Function CPUMonitorStartCPUMonitorStart must be called once at program initialization to start the CPU Monitor: int CPUMonitorStart(int Method); ParametersMethodCan have the following values: CPU_IDLE_TASK or CPU_COUNTER_TASK (see below for details). return valueThe method (CPU_IDLE_TASK or CPU_COUNTER_TASK) actually being used. Note that this value may differ from parameter Method. With method CPU_IDLE_TASK, CPUMoni will determine the amount of CPU time allocated to RTKernel-32's Idle Task(s). The CPU load returned by CPURelativeLoad is calculated from the total real time and the CPU time used by the Idle Tasks since the last call to CPURelativeLoad. This method will yield slightly different results depending on flag RF_ICPUTIME in RTKConfig.Flags. If this flag is not set, the time consumed by interrupt handlers is assumed to be used by the task being interrupted. With CPU_COUNTER_TASK, one task per CPU with priority 1 that counts in an endless loop is created. CPUMonitorStart will measure how fast these tasks can count when they run exclusively. Subsequent calls to CPURelativeLoad will evaluate how far the counting tasks have counted and calculate the amount of CPU time that was available to these tasks from the count rate. The CPU_COUNTER_TASK method only works if all other tasks (apart from RTKernel-32's Idle Tasks) have priorities greater than 1. In general, the CPU_IDLE_TASK method is more accurate since it is independent of cache and other CPU speed-distorting effects. However, it requires RTKConfig.Flags RF_TCPUTIME which is not set by default in the Standard Version of RTKernel-32. You must explicitly set flag RF_TCPUTIME before calling CPUMonitorStart if you want the CPU_IDLE_TASK method to be applied in the release version. Note that flag RF_TCPUTIME can have a negative impact on interrupt latency and performance, depending on the speed of the high resolution timer driver. On multiprocessor systems with Hyperthreading enabled, the counter tasks used with method CPU_COUNTER_TASK can slow down application tasks running on the same CPU. It is thus recommended not to use the CPU_COUNTER_TASK on Hyperthread systems. Either use RTKConfig driver flag DF_NO_HYPERTHREAD to switch off Hyperthreading or set flag RF_TCPUTIME to enable the use of method CPU_IDLE_TASK.
|