1 | Timer Driver |
---|
2 | ############ |
---|
3 | |
---|
4 | The timer driver is primarily used by the RTEMS Timing Tests. |
---|
5 | This driver provides as accurate a benchmark timer as possible. |
---|
6 | It typically reports its time in microseconds, CPU cycles, or |
---|
7 | bus cycles. This information can be very useful for determining |
---|
8 | precisely what pieces of code require optimization and to measure the |
---|
9 | impact of specific minor changes. |
---|
10 | |
---|
11 | The gen68340 BSP also uses the Timer Driver to support a high performance |
---|
12 | mode of the on-CPU UART. |
---|
13 | |
---|
14 | Benchmark Timer |
---|
15 | =============== |
---|
16 | |
---|
17 | The RTEMS Timing Test Suite requires a benchmark timer. The |
---|
18 | RTEMS Timing Test Suite is very helpful for determining |
---|
19 | the performance of target hardware and comparing its performance |
---|
20 | to that of other RTEMS targets. |
---|
21 | |
---|
22 | This section describes the routines which are assumed to exist by |
---|
23 | the RTEMS Timing Test Suite. The names used are *EXACTLY* what |
---|
24 | is used in the RTEMS Timing Test Suite so follow the naming convention. |
---|
25 | |
---|
26 | benchmark_timer_initialize |
---|
27 | -------------------------- |
---|
28 | |
---|
29 | Initialize the timer source. |
---|
30 | .. code:: c |
---|
31 | |
---|
32 | void benchmark_timer_initialize(void) |
---|
33 | { |
---|
34 | initialize the benchmark timer |
---|
35 | } |
---|
36 | |
---|
37 | Read_timer |
---|
38 | ---------- |
---|
39 | |
---|
40 | The ``benchmark_timer_read`` routine returns the number of benchmark |
---|
41 | time units (typically microseconds) that have elapsed since the last |
---|
42 | call to ``benchmark_timer_initialize``. |
---|
43 | .. code:: c |
---|
44 | |
---|
45 | benchmark_timer_t benchmark_timer_read(void) |
---|
46 | { |
---|
47 | stop time = read the hardware timer |
---|
48 | if the subtract overhead feature is enabled |
---|
49 | subtract overhead from stop time |
---|
50 | return the stop time |
---|
51 | } |
---|
52 | |
---|
53 | Many implementations of this routine subtract the overhead required |
---|
54 | to initialize and read the benchmark timer. This makes the times reported |
---|
55 | more accurate. |
---|
56 | |
---|
57 | Some implementations report 0 if the harware timer value change is |
---|
58 | sufficiently small. This is intended to indicate that the execution time |
---|
59 | is below the resolution of the timer. |
---|
60 | |
---|
61 | benchmark_timer_disable_subtracting_average_overhead |
---|
62 | ---------------------------------------------------- |
---|
63 | |
---|
64 | This routine is invoked by the "Check Timer" (``tmck``) test in the |
---|
65 | RTEMS Timing Test Suite. It makes the ``benchmark_timer_read`` |
---|
66 | routine NOT subtract the overhead required |
---|
67 | to initialize and read the benchmark timer. This is used |
---|
68 | by the ``tmoverhd`` test to determine the overhead |
---|
69 | required to initialize and read the timer. |
---|
70 | .. code:: c |
---|
71 | |
---|
72 | void benchmark_timer_disable_subtracting_average_overhead(bool find_flag) |
---|
73 | { |
---|
74 | disable the subtract overhead feature |
---|
75 | } |
---|
76 | |
---|
77 | The ``benchmark_timer_find_average_overhead`` variable is used to |
---|
78 | indicate the state of the "subtract overhead feature". |
---|
79 | |
---|
80 | gen68340 UART FIFO Full Mode |
---|
81 | ============================ |
---|
82 | |
---|
83 | The gen68340 BSP is an example of the use of the timer to support the UART |
---|
84 | input FIFO full mode (FIFO means First In First Out and roughly means |
---|
85 | buffer). This mode consists in the UART raising an interrupt when n |
---|
86 | characters have been received (*n* is the UART's FIFO length). It results |
---|
87 | in a lower interrupt processing time, but the problem is that a scanf |
---|
88 | primitive will block on a receipt of less than *n* characters. The solution |
---|
89 | is to set a timer that will check whether there are some characters |
---|
90 | waiting in the UART's input FIFO. The delay time has to be set carefully |
---|
91 | otherwise high rates will be broken: |
---|
92 | |
---|
93 | - if no character was received last time the interrupt subroutine was |
---|
94 | entered, set a long delay, |
---|
95 | |
---|
96 | - otherwise set the delay to the delay needed for *n* characters |
---|
97 | receipt. |
---|
98 | |
---|
99 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
100 | |
---|
101 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
102 | |
---|
103 | .. COMMENT: All rights reserved. |
---|
104 | |
---|