Presentation is loading. Please wait.

Presentation is loading. Please wait.

MED 304 Real-Time Solutions with Windows CE 5.0 Asang Dani Kanetkar School of Embedded Technology

Similar presentations


Presentation on theme: "MED 304 Real-Time Solutions with Windows CE 5.0 Asang Dani Kanetkar School of Embedded Technology"— Presentation transcript:

1

2 MED 304 Real-Time Solutions with Windows CE 5.0 Asang Dani Kanetkar School of Embedded Technology asang@ksetindia.com

3 Overview WinCE features Real-time Systems Real-time performance considerations Interrupt architecture Priority inversion Measurement tools

4 Architecture

5 OS Architecture

6 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)

7 Scheduler 32 processes Multiple threads per process Preemptive thread scheduler 256 priority levels 0-96Reserved for real-time above drivers 97-152Used by the default Windows CE- based device drivers 153-247Reserved for real-time below drivers 248 - 255Maps to non-real-time priorities

8 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

9 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

10 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

11 Real-time Performance considerations Memory Considerations Demand Paging Considerations File System Considerations GWES Considerations Other Considerations

12 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

13 Memory considerations Stack Reclaiming controlled by OEM dwNKMaxPrioNoScav – Highest priority for a thread that should not incur stack space recovery (default 247) CONTD

14 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 )

15 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

16 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

17 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

18 Remote kernel tracker

19 Preempt 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 Thread 3 High Priority Medium Priority Low Priority Thread 3 Resource Owner: Thread 2 Thread 1 Blocked Thread 2 Thread 1 Priority Boost Priority Inversion Preempt Blocked Priority Restored Thread 3 Fresh Quantum Thread 3

20 Kernel Interrupt Architecture HW All Higher Enabled All Except ID All OAL Thread ISR SetEvent ID ISH ISR 1 ISRN ISRLatency IST IST Latency

21 Interrupt Initialization // Create the Event gIntEvent= CreateEvent(NULL, // Security 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, &gIRQNum, sizeof(DWORD), &gSysIntNum, sizeof(DWORD), NULL); sizeof(DWORD), NULL); InterruptInitialize( gSysIntNum, // From Map gIntEvent, // Global Event NULL, // Not Used (DWORD)NULL // Not Used ) ) // Get the thread going ResumeThread( gThreadInt ); // Create the Event gIntEvent= CreateEvent(NULL, // Security 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, &gIRQNum, sizeof(DWORD), &gSysIntNum, sizeof(DWORD), NULL); sizeof(DWORD), NULL); InterruptInitialize( gSysIntNum, // From Map gIntEvent, // Global Event NULL, // Not Used (DWORD)NULL // Not Used ) ) // Get the thread going ResumeThread( gThreadInt ); Kernel HW All Higher Enabled All Except ID All OAL IST ISR SetEvent ID ISH ISR 1 ISR N IST

22 DWORDWINAPIThreadInt( 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; } DWORDWINAPIThreadInt( 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; } Kernel HW All Higher Enabled All Except ID All OAL IST ISR SetEvent ID ISR ISR 1 ISR N IST Interrupt Service Thread

23 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 Turns LED ON Waits 100 ms Turn LED OFF Increments and Sets Priority Sleeps 1 second Loop Sets Finished Event Push Button LED IST

24 Hardware

25 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]

26 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]

27 Debugging Strategies StrategyComments Application IDENice Integration and view of application data but not system Data Kernel DebuggerGreat system access; Requires OEM Integration into OS Debug ZonesSlow but ability to selectively enable debugging output Firmware DebuggerGreat Hardware access but difficult application level information Hardware DebuggerLast Resort when system is locked

28 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

29 Tools & Resources msdn.microsoft.com/ embedded microsoft.public. windowsxp.embedded windowsce.platbuilder windowsce.platbuilder windowsce.embedded.vc windowsce.embedded.vc blogs.msdn.com/mikehall Windows CE 5.0 Eval Kit Windows XP Embedded Eval Kit msdn.microsoft.com/ mobility microsoft.public. pocketpc.developer smartphone.developer dotnet.framework.compactframework blogs.msdn.com/ windowsmobile vsdteam netcfteam Windows Mobile 5.0 Eval Kit Websites Newsgroups Blogs Tools Build Develop

30 Your Feedback is Important! Please Fill Out the feedback form

31 © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.


Download ppt "MED 304 Real-Time Solutions with Windows CE 5.0 Asang Dani Kanetkar School of Embedded Technology"

Similar presentations


Ads by Google