Measurement tools

Download Report

Transcript Measurement tools

MED 304
Real-Time Solutions with
Windows CE 5.0
Asang Dani
Kanetkar School of Embedded Technology
[email protected]
Overview
WinCE features
Real-time Systems
Real-time performance considerations
Interrupt architecture
Priority inversion
Measurement tools
Architecture
OS Architecture
Application(s)
COREDLL
DEVICE.EXE
NK.EXE
GWES.EXE
SERVICES.EXE
FILESYS.EXE
DevMgr.Dll
OAL
RAM
ROM/
FLASH
Timer
INTC
CPU
Touch Display Keyboard
Object
Storage
ROM FS
Store
Manager
Block
Serial
Device
Custom
FTP
HARDWARE
Serial
USB
PCCard
(Function)
...
HTTPD TELNETD
WinCE Real-time Features
Preemptive multi-tasking
32 different processes
Priority inversion
Nested interrupts
One-millisecond system tick timing
Advanced thread timing and scheduling
Semaphores and other synchronization
objectives
High resolution timer (OEM)
Scheduler
32 processes
Multiple threads per process
Preemptive thread scheduler
256 priority levels
0-96
Reserved for real-time above drivers
97-152
153-247
Used by the default Windows CEbased device drivers
Reserved for real-time below drivers
248 - 255
Maps to non-real-time priorities
Real-time Systems
Set of all system elements
Hardware
operating system
applications
RTOS is one of the elements
Application domains
manufacturing process controls
high-speed data acquisition devices
telecommunications switching equipment
WinCE Real-time
Performance
Guaranteed upper bound on high-priority
thread scheduling
Guaranteed upper bound on delay in
executing high-priority ISRs
Fine control over scheduler and how it
schedules threads
Adjustable Thread quantum
Measurement tools
System Response times
Predictable factors - processor, clock,
bus speed
Unpredictable
Processor cache
IST is current thread?
Filesystem
Options
Adjust the priorities of system's ISTs
Interrupt batching
Faster processor, bus etc
Real-time Performance
considerations
Memory Considerations
Demand Paging Considerations
File System Considerations
GWES Considerations
Other Considerations
Memory considerations
Allocate memory for kernel objects
whenever a process starts
Virtual memory
VirtualAlloc – Commit a region of
pages in VA space of caller
Caching can also be disabled
Heaps
Local – first-fit algorithm
Make uniform allocations
Stack
Committed when thread is first scheduled
Kernel reclaims unused stack memory
Memory considerations
Stack
Reclaiming controlled by OEM
dwNKMaxPrioNoScav – Highest priority for a
thread that should not incur stack space
recovery (default 247)
CONTD
Demand Paging considerations
Code is paged; data is not
Can make response time unpredictable
Can be disabled for
Entire system by setting ROMFLAGS=0x01 in
Config.bib
An individual dynamic-link library (DLL) by
using LoadDriver
File system driver that doesn’t support it
(HKEY_LOCAL_MACHINE\System\StorageManager\
FATFS\Paging)
Filesystem & GWES
Considerations
Filesystem drivers are NOT real-time
use critical sections
using single critical section per FS can block
higher priority threads
GWES
has no guaranteed latency
utilizes single critical section
can also worsen the performance through
it’s use of display drivers
Other Considerations
Power management
Frequent cycles in and out of idle state
should be avoided
OEMIdle should be a no-op.
Peripheral access
Reading from CMOS clock – optimize in
software
Working with system bus – find out how
drivers in your system affect RT processing
Display drivers that use hardware acceleration
lock system bus for extended duration
Remote Kernel Tracker
Thread interactions
Internal dependencies
System state information
System events, mapped onto thread that
was executing at the time they occurred
System interrupts
All processes and threads in the system
Custom events
Remote kernel tracker
Priority Inversion
Thread 1 blocked waiting for resource owned by Thread 3,
causing Priority Inversion
Avoid priority inversion by keeping all threads waiting for
same resource at the same priority
Priority
Priority Priority
Inversion Boost
Restored
Thread 1 Blocked
High Priority
Thread 1
Preempt
Thread 2
Thread 2 Thread 3
Medium Priority
Fresh
Quantum
Preempt
Low Priority
Thread 3
Thread 3
Blocked
Resource Owner:
Thread 3
Thread 1
Interrupt Architecture
Thread
IST Latency
IST
ISR1
ISRN
OAL
ISR
Latency
ID
ISR
Kernel
Set
Event
ISH
All Except
ID
All
HW
All Higher Enabled
Interrupt Initialization
ISR1
IST
IST
ISRN
OAL
ID
Set
Event
All Higher Enabled
All Except All
ID
HW
InterruptInitialize( gSysIntNum, // From Map
gIntEvent,
// Global Event
NULL,
// Not Used
(DWORD)NULL // Not Used ) )
// Get the thread going
ResumeThread( gThreadInt );
ISR
Kernel
// Create the Event
gIntEvent
= CreateEvent(NULL, // Security
ISH
FALSE,
// Manual reset
FALSE,
// Init as not signaled
NULL
// No Named Events );
// Create a thread that waits for signaling
gThreadInt = CreateThread(
NULL,
// Security
0,
// Default
ThreadInt,// Interrupt Thread
NULL,
// No Parameters
CREATE_SUSPENDED,// Suspended
&dwThreadID // Thread Id);
// Initilialize the Interrupt
gSysInterruptNum = KernelIoControl( IOCTL_HAL_TRANSLATE_IRQ,
&gIRQNum, sizeof(DWORD), &gSysIntNum,
sizeof(DWORD), NULL);
Interrupt Service Thread
ISR1
IST
IST
ISRN
OAL
ISR
ID
DWORD
{
WINAPI
ThreadInt( LPVOID lpvParam )
while( gRun )
{
// Wait until we have been signaled interrupt
WaitForSingleObject( gIntEvent, INFINITE );
// Increment the counter
gInterruptCount++;
// your logic here …
// Reset the interrupt
InterruptDone( gSysIntNum );
}
return 0;
}
All Except All
ID
HW
All Higher Enabled
Kernel
Set
Event
ISR
Priority Runner Strategy
Create a thread that runs priorities
IST runs, LED blinks
Stops Blinking when it isn’t scheduled!
Waits for Start Event
Check if Reached Stop Priority
Push Button
IST
Turns LED ON
Waits 100 ms
Turn LED OFF
Increments and Sets Priority
Sleeps 1 second
LED
Loop
Sets Finished Event
Hardware
Push-On/Push-Off Switch
Radio Shack Part # 275-011A
Connects Pins 4-8
(DTR To CTS)
Button
Anode
D-Sub Connector 9 Position Female
Radio Shack Part # 276-1428
LED
RED LED 12V - 30 ma
Radio Shack Part # 276-011
Connects Pins 5-7
(GND to RTS)
Cathode
RS232 DB9 Connector
DB-9M
Function
Pin
Pin
Pin
Pin
Pin
Pin
Pin
Pin
Pin
Data Carrier Detect CD
Receive Data
RD or RX or RXD
Transmitted Data
TD or TX or TXD
Data Terminal Ready DTR
Signal Ground
GND
Data Set Ready
DSR
Request To Send
RTS
Clear To Send
CTS
Ring Indicator
RI
#1
#2
#3
#4
#5
#6
#7
#8
#9
Abbreviation
Measurement tools - ILTiming
Determines ISR and IST latencies
Jitter – variance of interrupt latencies
ISR and IST jitters should be as small as
possible
Uses timer interrupt to measure latencies
Allows creating idle background threads
Affect IST latencies by enabling kernel to be in
a non-preemptive call (must finish before IST
is run)
iltiming [-i0] [-i1] [-i2] [-i3] [-i4] [-p priority] [-ni]
[-t interval] [-n interrupt] [-all] [-o file_name] [-h]
Measurement tools - OSBench
Collects timing samples for kernel
performance measurement
Determines time taken for:
Critical Section acquire or release
Event wait or signal
Semaphore/Mutex Create
Thread yield
System API calls
osbench [-all] [-t test_case] [-list] [-v] [-n number]
[-m address] [-o file_name] [-h]
Debugging Strategies
Strategy
Application IDE
Kernel Debugger
Debug Zones
Firmware Debugger
Hardware Debugger
Comments
Nice Integration and view of
application data but not system
Data
Great system access; Requires
OEM Integration into OS
Slow but ability to selectively
enable debugging output
Great Hardware access
but difficult application level
information
Last Resort when system is
locked
Summary
Real-time is system property
Real-time performance considerations
IST – ISR Interrupt Model
Coordination through an OS Event
CE 5.0 provides RTOS Environment
Priorities/Quantums/Inversion/paging
controls
Measurement tools
Integrated Kernel Tracker, Debugger,
Profiler
Tools & Resources
Websites
Newsgroups
Build
Develop
msdn.microsoft.com/
embedded
msdn.microsoft.com/
mobility
microsoft.public.
windowsxp.embedded
windowsce.platbuilder
windowsce.embedded.vc
microsoft.public.
pocketpc.developer
smartphone.developer
dotnet.framework.compactframework
Blogs
blogs.msdn.com/mikehall
Tools
Windows CE 5.0 Eval Kit
Windows XP Embedded Eval Kit
blogs.msdn.com/
windowsmobile
vsdteam
netcfteam
Windows Mobile 5.0 Eval Kit
Your Feedback
is Important!
Please Fill Out the
feedback form
© 2005 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.