source: rtems/doc/user/cpuuse.t @ 4ffbc49

4.104.114.95
Last change on this file since 4ffbc49 was 4ffbc49, checked in by Glenn Humphrey <glenn.humphrey@…>, on 10/25/07 at 19:46:41

2007-10-25 Glenn Humphrey <glenn.humphrey@…>

  • user/barrier.t, user/clock.t, user/concepts.t, user/cpuuse.t, user/init.t, user/intr.t, user/io.t, user/mp.t, user/rtmon.t, user/sem.t, user/stackchk.t, user/task.t, user/timer.t: Updated the Ada documentation to reflect the current binding.
  • Property mode set to 100644
File size: 4.6 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-2007.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6@c  $Id$
7@c
8
9@chapter CPU Usage Statistics
10
11@section Introduction
12
13The CPU usage statistics manager is an RTEMS support
14component that provides a convenient way to manipulate
15the CPU usage information associated with each task
16The routines provided by the CPU usage statistics manager are:
17
18@itemize @bullet
19@item @code{@value{DIRPREFIX}cpu_usage_report} - Report CPU Usage Statistics
20@item @code{@value{DIRPREFIX}cpu_usage_reset} - Reset CPU Usage Statistics
21@end itemize
22
23@section Background
24
25When analyzing and debugging real-time applications, it is important
26to be able to know how much CPU time each task in the system consumes.
27This support component provides a mechanism to easily obtain this
28information with little burden placed on the target.
29
30The raw data is gathered as part of performing a context switch.  RTEMS
31keeps track of how many clock ticks have occurred which the task being
32switched out has been executing.  If the task has been running less than
331 clock tick, then for the purposes of the statistics, it is assumed to
34have executed 1 clock tick.  This results in some inaccuracy but the
35alternative is for the task to have appeared to execute 0 clock ticks.
36
37RTEMS versions newer than the 4.7 release series, support the ability
38to obtain timestamps with nanosecond granularity if the BSP provides
39support.  It is a desirable enhancement to change the way the usage
40data is gathered to take advantage of this recently added capability.
41Please consider sponsoring the core RTEMS development team to add
42this capability.
43
44@section Operations
45
46@subsection Report CPU Usage Statistics
47
48The application may dynamically report the CPU usage for every
49task in the system by calling the
50@code{@value{DIRPREFIX}cpu_usage_report} routine.
51This routine prints a table with the following information per task:
52
53@itemize @bullet
54@item task id
55@item task name
56@item number of clock ticks executed
57@item percentage of time consumed by this task
58@end itemize
59
60The following is an example of the report generated:
61
62@example
63@group
64CPU Usage by thread
65   ID        NAME        TICKS    PERCENT
660x04010001   IDLE           0     0.000
670x08010002   TA1         1203     0.748
680x08010003   TA2          203     0.126
690x08010004   TA3          202     0.126
70
71Ticks since last reset = 1600
72
73Total Units = 1608
74@end group
75@end example
76
77Notice that the "Total Units" is greater than the ticks per reset.
78This is an artifact of the way in which RTEMS keeps track of CPU
79usage.  When a task is context switched into the CPU, the number
80of clock ticks it has executed is incremented.  While the task
81is executing, this number is incremented on each clock tick. 
82Otherwise, if a task begins and completes execution between
83successive clock ticks, there would be no way to tell that it
84executed at all.
85
86Another thing to keep in mind when looking at idle time, is that
87many systems -- especially during debug -- have a task providing
88some type of debug interface.  It is usually fine to think of the
89total idle time as being the sum of the IDLE task and a debug
90task that will not be included in a production build of an application.
91
92@subsection Reset CPU Usage Statistics
93
94Invoking the @code{@value{DIRPREFIX}cpu_usage_reset} routine resets
95the CPU usage statistics for all tasks in the system.
96
97@section Directives
98
99This section details the CPU usage statistics manager's directives.
100A subsection is dedicated to each of this manager's directives
101and describes the calling sequence, related constants, usage,
102and status codes.
103
104@page
105@subsection cpu_usage_report - Report CPU Usage Statistics
106
107@subheading CALLING SEQUENCE:
108
109@ifset is-C
110@example
111void rtems_cpu_usage_report( void );
112@end example
113@end ifset
114
115@ifset is-Ada
116@example
117procedure CPU_Usage_Report;
118@end example
119@end ifset
120
121@subheading STATUS CODES: NONE
122
123@subheading DESCRIPTION:
124
125This routine prints out a table detailing the CPU usage statistics for
126all tasks in the system.
127
128@subheading NOTES:
129
130The table is printed using the @code{printk} routine.
131
132@page
133@subsection cpu_usage_reset - Reset CPU Usage Statistics
134
135@subheading CALLING SEQUENCE:
136
137@ifset is-C
138@example
139void rtems_cpu_usage_reset( void );
140@end example
141@end ifset
142
143@ifset is-Ada
144@example
145procedure CPU_Usage_Reset;
146@end example
147@end ifset
148
149@subheading STATUS CODES: NONE
150
151@subheading DESCRIPTION:
152
153This routine re-initializes the CPU usage statistics for all tasks
154in the system to their initial state.  The initial state is that
155a task has not executed and thus has consumed no CPU time.
156default state which is when zero period executions have occurred.
157
158@subheading NOTES:
159
160NONE
Note: See TracBrowser for help on using the repository browser.