⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kernel-characterization.html

📁 ecos 文档
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!-- Copyright (C) 2003 Red Hat, Inc.                                -->
<!-- This material may be distributed only subject to the terms      -->
<!-- and conditions set forth in the Open Publication License, v1.0  -->
<!-- or later (the latest version is presently available at          -->
<!-- http://www.opencontent.org/openpub/).                           -->
<!-- Distribution of the work or derivative of the work in any       -->
<!-- standard (paper) book form is prohibited unless prior           -->
<!-- permission is obtained from the copyright holder.               -->
<HTML
><HEAD
><TITLE
>Kernel Real-time Characterization</TITLE
><meta name="MSSmartTagsPreventParsing" content="TRUE">
<META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="eCos Reference Manual"
HREF="ecos-ref.html"><LINK
REL="UP"
TITLE="The eCos Kernel"
HREF="kernel.html"><LINK
REL="PREVIOUS"
TITLE="Interrupt Handling"
HREF="kernel-interrupts.html"><LINK
REL="NEXT"
TITLE="RedBoot&#8482; User's Guide"
HREF="redboot.html"></HEAD
><BODY
CLASS="REFENTRY"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>eCos Reference Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="kernel-interrupts.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="redboot.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="KERNEL-CHARACTERIZATION">Kernel Real-time Characterization</H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN2068"
></A
><H2
>Name</H2
>tm_basic&nbsp;--&nbsp;Measure the performance of the eCos kernel</DIV
><DIV
CLASS="REFSECT1"
><A
NAME="KERNEL-CHARACTERIZATION-DESCRIPTION"
></A
><H2
>Description</H2
><P
>When building a real-time system, care must be taken to ensure that
the system will be able to perform properly within the constraints of
that system. One of these constraints may be how fast certain
operations can be performed. Another might be how deterministic the
overall behavior of the system is. Lastly the memory footprint (size)
and unit cost may be important.
        </P
><P
>One of the major problems encountered while evaluating a system will
be how to compare it with possible alternatives. Most manufacturers of
real-time systems publish performance numbers, ostensibly so that
users can compare the different offerings. However, what these numbers
mean and how they were gathered is often not clear. The values are
typically measured on a particular piece of hardware, so in order to
truly compare, one must obtain measurements for exactly the same set
of hardware that were gathered in a similar fashion.
        </P
><P
>Two major items need to be present in any given set of measurements.
First, the raw values for the various operations; these are typically
quite easy to measure and will be available for most systems. Second,
the determinacy of the numbers; in other words how much the value
might change depending on other factors within the system. This value
is affected by a number of factors: how long interrupts might be
masked, whether or not the function can be interrupted, even very
hardware-specific effects such as cache locality and pipeline usage.
It is very difficult to measure the determinacy of any given
operation, but that determinacy is fundamentally important to proper
overall characterization of a system.
        </P
><P
>In the discussion and numbers that follow, three key measurements are
provided. The first measurement is an estimate of the interrupt
latency: this is the length of time from when a hardware interrupt
occurs until its Interrupt Service Routine (ISR) is called. The second
measurement is an estimate of overall interrupt overhead: this is the
length of time average interrupt processing takes, as measured by the
real-time clock interrupt (other interrupt sources will certainly take
a different amount of time, but this data cannot be easily gathered).
The third measurement consists of the timings for the various kernel
primitives.
          </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="KERNEL-CHARACTERIZATION-METHODOLOGY"
></A
><H2
>Methodology</H2
><P
>Key operations in the kernel were measured by using a simple test
program which exercises the various kernel primitive operations. A
hardware timer, normally the one used to drive the real-time clock,
was used for these measurements. In most cases this timer can be read
with quite high resolution, typically in the range of a few
microseconds. For each measurement, the operation was repeated a
number of times. Time stamps were obtained directly before and after
the operation was performed. The data gathered for the entire set of
operations was then analyzed, generating average (mean), maximum and
minimum values. The sample variance (a measure of how close most
samples are to the mean) was also calculated. The cost of obtaining
the real-time clock timer values was also measured, and was subtracted
from all other times.
          </P
><P
>Most kernel functions can be measured separately. In each case, a
reasonable number of iterations are performed. Where the test case
involves a kernel object, for example creating a task, each iteration
is performed on a different object. There is also a set of tests which
measures the interactions between multiple tasks and certain kernel
primitives. Most functions are tested in such a way as to determine
the variations introduced by varying numbers of objects in the system.
For example, the mailbox tests measure the cost of a 'peek' operation
when the mailbox is empty, has a single item, and has multiple items
present. In this way, any effects of the state of the object or how
many items it contains can be determined.
          </P
><P
>There are a few things to consider about these measurements. Firstly,
they are quite micro in scale and only measure the operation in
question. These measurements do not adequately describe how the
timings would be perturbed in a real system with multiple interrupting
sources. Secondly, the possible aberration incurred by the real-time
clock (system heartbeat tick) is explicitly avoided. Virtually all
kernel functions have been designed to be interruptible. Thus the
times presented are typical, but best case, since any particular
function may be interrupted by the clock tick processing. This number
is explicitly calculated so that the value may be included in any
deadline calculations required by the end user. Lastly, the reported
measurements were obtained from a system built with all options at
their default values. Kernel instrumentation and asserts are also
disabled for these measurements. Any number of configuration options
can change the measured results, sometimes quite dramatically. For
example, mutexes are using priority inheritance in these measurements.
The numbers will change if the system is built with priority
inheritance on mutex variables turned off.
          </P
><P
>The final value that is measured is an estimate of interrupt latency.
This particular value is not explicitly calculated in the test program
used, but rather by instrumenting the kernel itself. The raw number of
timer ticks that elapse between the time the timer generates an
interrupt and the start of the timer ISR is kept in the kernel. These
values are printed by the test program after all other operations have
been tested. Thus this should be a reasonable estimate of the
interrupt latency over time.
          </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="KERNEL-CHARACTERIZATION-USING-MEASUREMENTS"
></A
><H2
>Using these Measurements</H2
><P
>These measurements can be used in a number of ways. The most typical
use will be to compare different real-time kernel offerings on similar
hardware, another will be to estimate the cost of implementing a task
using eCos (applications can be examined to see what effect the kernel
operations will have on the total execution time). Another use would
be to observe how the tuning of the kernel affects overall operation.
          </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="KERNEL-CHARACTERIZATION-INFLUENCES"
></A
><H2
>Influences on Performance</H2
><P
>A number of factors can affect real-time performance in a system. One
of the most common factors, yet most difficult to characterize, is the
effect of device drivers and interrupts on system timings. Different
device drivers will have differing requirements as to how long
interrupts are suppressed, for example. The eCos system has been
designed with this in mind, by separating the management of interrupts
(ISR handlers) and the processing required by the interrupt
(DSR&#8212;Deferred Service Routine&#8212; handlers). However, since
there is so much variability here, and indeed most device drivers will
come from the end users themselves, these effects cannot be reliably
measured. Attempts have been made to measure the overhead of the
single interrupt that eCos relies on, the real-time clock timer. This
should give you a reasonable idea of the cost of executing interrupt
handling for devices.
          </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="KERNEL-CHARACTERIZATION-MEASURED-ITEMS"
></A
><H2
>Measured Items</H2
><P
>This section describes the various tests and the numbers presented.
All tests use the C kernel API (available by way of
<TT
CLASS="FILENAME"
>cyg/kernel/kapi.h</TT
>). There is a single main thread
in the system that performs the various tests. Additional threads may
be created as part of the testing, but these are short lived and are
destroyed between tests unless otherwise noted. The terminology
&#8220;lower priority&#8221; means a priority that is less important,
not necessarily lower in numerical value. A higher priority thread
will run in preference to a lower priority thread even though the
priority value of the higher priority thread may be numerically less
than that of the lower priority thread.
          </P
><DIV
CLASS="REFSECT2"
><A
NAME="KERNEL-CHARACTERIZATION-MEASURE-THREADS"
></A
><H3
>Thread Primitives</H3
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Create thread</DT
><DD
><P
>This test measures the <TT
CLASS="FUNCTION"
>cyg_thread_create()</TT
> call.
Each call creates a totally new thread. The set of threads created by
this test will be reused in the subsequent thread primitive tests.
                </P
></DD
><DT
>Yield thread</DT
><DD
><P
>This test measures the <TT
CLASS="FUNCTION"
>cyg_thread_yield()</TT
> call.
For this test, there are no other runnable threads, thus the test
should just measure the overhead of trying to give up the CPU.
                </P
></DD
><DT
>Suspend &#0091;suspended&#0093; thread</DT
><DD
><P
>This test measures the <TT
CLASS="FUNCTION"
>cyg_thread_suspend()</TT
> call.
A thread may be suspended multiple times; each thread is already
suspended from its initial creation, and is suspended again.
                </P
></DD
><DT
>Resume thread</DT
><DD
><P
>This test measures the <TT
CLASS="FUNCTION"
>cyg_thread_resume()</TT
> call.
All of the threads have a suspend count of 2, thus this call does not
make them runnable. This test just measures the overhead of resuming a
thread.
                </P
></DD
><DT
>Set priority</DT
><DD
><P
>This test measures the <TT
CLASS="FUNCTION"
>cyg_thread_set_priority()</TT
>
call. Each thread, currently suspended, has its priority set to a new
value.
                </P
></DD
><DT
>Get priority</DT
><DD
><P
>This test measures the <TT
CLASS="FUNCTION"
>cyg_thread_get_priority()</TT
>
call.
                </P
></DD
><DT
>Kill &#0091;suspended&#0093; thread</DT
><DD
><P
>This test measures the <TT
CLASS="FUNCTION"
>cyg_thread_kill()</TT
> call.
Each thread in the set is killed. All threads are known to be
suspended before being killed.
		</P
></DD
><DT
>Yield &#0091;no other&#0093; thread</DT
><DD
><P
>This test measures the <TT
CLASS="FUNCTION"
>cyg_thread_yield()</TT
> call
again. This is to demonstrate that the
<TT
CLASS="FUNCTION"
>cyg_thread_yield()</TT
> call has a fixed overhead,
regardless of whether there are other threads in the system.
                </P
></DD
><DT
>Resume &#0091;suspended low priority&#0093; thread</DT
><DD
><P
>This test measures the <TT
CLASS="FUNCTION"
>cyg_thread_resume()</TT
> call
again. In this case, the thread being resumed is lower priority than
the main thread, thus it will simply become ready to run but not be
granted the CPU. This test measures the cost of making a thread ready
to run.
                </P
></DD
><DT
>Resume &#0091;runnable low priority&#0093; thread</DT
><DD
><P
>This test measures the <TT
CLASS="FUNCTION"
>cyg_thread_resume()</TT
> call
again. In this case, the thread being resumed is lower priority than
the main thread and has already been made runnable, so in fact the
resume call has no effect.
                </P
></DD
><DT
>Suspend &#0091;runnable&#0093; thread</DT
><DD
><P
>This test measures the <TT
CLASS="FUNCTION"
>cyg_thread_suspend()</TT
> call
again. In this case, each thread has already been made runnable (by
previous tests).
                </P
></DD
><DT
>Yield &#0091;only low priority&#0093; thread</DT
><DD
><P
>This test measures the <TT
CLASS="FUNCTION"
>cyg_thread_yield()</TT
> call.
In this case, there are many other runnable threads, but they are all
lower priority than the main thread, thus no thread switches will take
place.
                </P
></DD
><DT
>Suspend &#0091;runnable-&gt;not runnable&#0093; thread</DT
><DD
><P
>This test measures the <TT
CLASS="FUNCTION"
>cyg_thread_suspend()</TT
> call
again. The thread being suspended will become non-runnable by this
action.
                </P
></DD
><DT
>Kill &#0091;runnable&#0093; thread</DT
><DD
><P

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -