
EMB317 Real-Time Solutions With Windows CE 5.0 Nat Frampton President Real Time Development Corp nat@realtimeonline.com MEDC DevCon 2005
EMB317 Real-Time Solutions With Windows CE 5.0 Nat Frampton President Real Time Development Corp. nat@realtimeonline.com

Microsoft MEDC Mobile Embedded DevCon 2005 May9-12,2005 Las Vegas Microsoft

Windows Mobile 出 Windows CE5.0 Windows EDcoc Hardware/Drivers OEM/IHV Supplied BSP OEM Hardware and Standard PC (ARM,SH4,MIPS) Standard Drivers Hardware and Drivers Device Building Windows XP DDK Tools Platform Builder Windows Embedded Studio Lightweight EDB SQL Server 2005 Express Edition Relational SQL Server 2005 Mobile Edition SQL Server 2005 Native Win32 MFC 8.0,ATL 8.0 Managed .NET Compact Framework .NET Framework server side ASP.NET Mobile Controls ASP.NET Windows Media Multimedia Direct议 Location services MapPoint Development Tools Visual Studio 2005 Internet Security and Acceleration Server communications Exchange Server &Messaging Live Communications Server Speech Server Device Update Agent Management Image Update Software Update Services Tools Systems Management Server Microsoft Operations Manager
Management Tools Communications & Messaging Device Update Agent Software Update Services Live Communications Server Exchange Server Internet Security and Acceleration Server Speech Server Image Update Location Services Multimedia MapPoint DirectX Windows Media Development Tools Visual Studio 2005 MFC 8.0, ATL 8.0 Native Win32 Managed Server Side Lightweight Relational EDB SQL Server 2005 Express Edition Data Programming Model Device Building Tools Hardware/Drivers Windows XP DDK Windows Embedded Studio Platform Builder OEM/IHV Supplied BSP (ARM, SH4, MIPS) OEM Hardware and Standard Drivers Standard PC Hardware and Drivers SQL Server 2005 Mobile Edition SQL Server 2005 ASP.NET Mobile Controls ASP.NET .NET Compact Framework .NET Framework Microsoft Operations Manager Systems Management Server

Overview Understanding Interrupts Interrupt Architecture Deadlock Thread Strategy Priority Runner Strategy Lessons Learned
Overview Understanding Interrupts Interrupt Architecture Deadlock Thread Strategy Priority Runner Strategy Lessons Learned

Real Time OMAC represents Industrial Automation Community Industry Reviewed 100s of Applications Hard Real Time Applications where system fails if timings are not meet Soft Real Time Applications where system tolerates large latencies
Real Time OMAC represents Industrial Automation Community Industry Reviewed 100s of Applications Hard Real Time Applications where system fails if timings are not meet Soft Real Time Applications where system tolerates large latencies

Real Time Example Simple Material Handling of Boxes Soft Real-Time System Requires Stop Hard Real-Time Reduces Hardware Hard Real-Time Improves Throughput. Soft Real-Time System Hard Real-Time System Controlle Box Senso Box Sensor
Real Time Example Simple Material Handling of Boxes Soft Real-Time System Requires Stop Hard Real-Time Reduces Hardware Hard Real-Time Improves Throughput. Stop Divert Area Box Controller Box Sensor Interrupt Soft Real-Time System Divert Area Box Controller Box Sensor Interrupt Hard Real-Time System

Real Time Defined 100ms 20 ms 10m Windows Windows 5ms Hard 90% CE.2.X NT Apps 1ms Windows 500u5 CE.net 100 1,000 5,000 10,000 Cycle Variation (us)
Real Time Defined •Hard Real-Time 0 1,000 5,000 10,000 Cycle Variation (us) 500 us 1 ms 5 ms 10 ms 20 ms 100 ms Cycle Time Hard Real Time 100 Windows Soft Real-Time CE® 2.X Windows NT® Windows CE .net 90% Apps

Interrupt Architecture IST Latency IST Thread ISR ISR ISR Latency ISR D Set ISR Kernel Event All Higher Enabled All Except A ID
Kernel Interrupt Architecture HW All Higher Enabled All Except ID All OAL Thread ISR Set Event ID ISR ISR1 ISRN ISR Latency IST IST Latency

Interrupt Initialization IST ISR //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 ,//Interrupt Thread ns5eo。reas /Initilialize the Interrupt gSysInterruptNum KernelIocontrol(IOCTL_HAL TRANSLATE_IRQ &gIRQNum,sizeof(DWORD),&gsysIntNum,sizeof (DWORD),NULL ) InterruptInitialize(gsysIntNum,/From Map gIntEvent, //Global Event NULL, /Not Used (DWORD)NULL /Not Used ) /Get the thread going ResumeThread(gThreadInt )
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, 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 Set Event I D ISR ISR1 ISRN IST

Interrupt Service Thread ISR DWORD WINAPI ThreadInt(LPVOID 1pvParam 四图回美 /The magic thread waits for the event. while(gRun /wait until we have been signaled interrupt waitForsingleobject(gIntEvent,INFINITE ) /Increment the counter gInterruptCount ++ /Run your logic here /Reset the interrupt InterruptDone(gsysIntNum ) return 0;
Interrupt Service Thread DWORD WINAPI ThreadInt( LPVOID lpvParam ) { // The magic thread waits for the event. while( gRun ) { // Wait until we have been signaled interrupt WaitForSingleObject( gIntEvent, INFINITE ); // Increment the counter gInterruptCount ++; // Run your logic here // Reset the interrupt InterruptDone( gSysIntNum ); } return 0; } Kernel HW All Higher Enabled All Except ID All OAL IST ISR Set Event I D ISR ISR1 ISRN IST