280 likes | 423 Views
Operating systems. Windows CE (WinCE). Goals. Support lightweight consumer devices: PDAs. Set-top boxes. Simplify porting existing Windows applications to the new platforms. WinCE architecture. Applications. Embedded shell. Remote connectivity. WinCE shell services. Win32 APIs. Kernel
E N D
Operating systems • Windows CE (WinCE). Overheads for Computers as Components
Goals • Support lightweight consumer devices: • PDAs. • Set-top boxes. • Simplify porting existing Windows applications to the new platforms. Overheads for Computers as Components
WinCE architecture Applications Embedded shell Remote connectivity WinCE shell services Win32 APIs Kernel library GWES Device manager File manager IrDA TCP/IP OAL bootload drivers Device drivers File drivers Network drivers OEM hardware Overheads for Computers as Components
Virtual memory • WinCE uses virtual memory. • Most devices don’t have disk drive. • Code can be paged from ROM, etc. • WinCE suports a flat 32-bit virtual address space. • Virtual address may be: • Statically mapped (kernel-mode code). • Dynamically mapped (user-mode and some kernel-mode code). Overheads for Computers as Components
Address space Kernel space • Bottom half is user space. • Top half is kernel space. 2 GB User space 2 GB Overheads for Computers as Components
Kernel address space • Operating system (nk.exe). • Statically mapped virtual addresses. • Up to 512 MB of physical resources can be statically mapped. • Control of static mapping varies: • OEM control for ARM and x86. • CPU control for SHx and MIPS. Overheads for Computers as Components
User address space • 64 slots of 32 MB each. • Slot 0 is currently running process. • Slots 1-33 are the processes. • 32 processes max. • Object store, memory mapped files, resource mappings. Slot 63: resource mappings Slots 33-62: object store, memory mapped files … Slot 3: process Slot 2: process Slot 1: DLLs Slot 0: current process Overheads for Computers as Components
Process slot • Includes code, DLL and virtual allocations. • Virtual allocations are 64 KB-aligned; 4KB pages can be committed within an allocation. • Movement: • DLL allocations start at the top and grow down. • Process and general allocations start at the bottom and grow up. DLL virtual memory allocations User code: Stack, heap per thread Guard section (64K) Overheads for Computers as Components
API calls • System call may be to DLL, another EXE. • COREDLL provides link between system API and EXE. • System call: • Exception caught by kernel. • Kernel determines which EXE gets the call. Overheads for Computers as Components
Driver structure • A driver is a DLL with particular interface points. • Hosted by a device manager process space (may be GWES). • Handle interrupts by dedicated IST thread. • Synchronize driver and application via critical sections and MUTEXes. Overheads for Computers as Components
Driver architecture Device I/O RM GWES PCI bus display battery network audio Firewire USB host touch mouse PCMCIA host Notification LED Overheads for Computers as Components
Device manager • Always-running user-level process. • Contains the I/O Resource Manager. • Loads the registry enumerator DLL which in turn loads drivers. • Provides power notification callbacks. Overheads for Computers as Components
Registry enumerator • DLL (RegEum.dll). • Re-entrant, supports hierarchical usage. • Driver loading: • RegEnum scans registry, loads bus drivers. • Bus driver scans bus, locates devices. • Searches registry for device information. • Loads appropriate drivers. • Sends notification that interface is available. Overheads for Computers as Components
Interrupt handling • Work divided into two sections: • Interrupt service routine (ISR): • Kernel mode service. • May be static or installable. • Interrupt service thread (IST): • User mode thread. Overheads for Computers as Components
Static ISR • Built into the kernel. • SHx and MIPS must be written in assembler, limited register availability. • One-way communication from ISR to IST. • Can share a buffer but location must be predefined. • Nested ISR support based on CPU, OEM’s initialization. • Stack is provided by the kernel. Overheads for Computers as Components
Installable ISR • Can be dynamically loaded into kernel. • Loads a C DLL. • Can use shared memory for communication. • ISRs are processed in the order they were installed. • Limited stack size. Overheads for Computers as Components
WinCE 4.x interrupts IST processing thread ISR ISR I-ISR ISR ISR OAL ISH Set event Enable ID kernel device All higher enabled All enabled Except ID All enabled HW Overheads for Computers as Components
Kernel scheduler • Two styles of preemptive multitasking. • Thread runs until end of quantum. • Thread runs until higher priority thread is ready to run. • Round-robin within priority level. • Quantum is defined by OEM and application. • Priority inheritance to control priority inversion. • 256 total priorities. • Top 248 can be protected by the OEM. Overheads for Computers as Components
Thread quantum • Per-thread quantum. • Default set by OEM. • Use API to set quantum. • Quantum of 0 means run-to-completion. Overheads for Computers as Components
System tick • 1 ms timer tick normally. • Sleep(N) will generally wake up in N to N+1 ms. Overheads for Computers as Components
Causes of interrupt latency • ISR: • Amount of time that interrupts are turned off. • Time required to vector ISR, save registers, etc. • IST: • Time spent in ISR. • Time spent in Kcall. • Thread scheduling time. Overheads for Computers as Components
Improvements to latency in WinCE 4.x • Less non-preemptable code. • Some routines split into several smaller routines. • Kernel data structures moved to statically mapped virtual addresses. • Special-case ISTs provided. • Improved priority inversion handling. Overheads for Computers as Components
Controlling scheduling/latency • Thread scheduling: • Set priorities appropriately, choose proper quantum. • Memory: • Preallocate memory, threads, sync objects. • Understand device characteristics: • I/O-based access may incur a penalty. • On x86 avoid using CMOS real-time clock, use software real-time clock. • Disable idle processing. • Disable demand paging. Overheads for Computers as Components
Real-time measurement • ILTiming • Software-based real-time measurement tool. • Measures ISR latency from IRQ to ISR. • Measures IST latency from end of ISR to start of IST. • Kernel tracker • Tracks interrupts, TLB misses, and priority inversion. Overheads for Computers as Components
Board support package • Customizes OS for a hardware platform. • Drivers, memory configuration, power management, etc. • Software development environment provides tools for BSP development. Overheads for Computers as Components
BSP development process Test HW Clone Reference BSP Develop Boot loader Power management Add device drivers Develop Minimal kernel Package BSP Overheads for Computers as Components
Boot loader • The Boot loader loads an executable image and runs it. • Loadable by Ethernet, USB, serial, local flash, etc. • Memory may be flash or ROM. • May need different development, production loaders. Overheads for Computers as Components
OAL architecture Kernel (Microsoft) OAL RTC Power Mgt. interrupt functions debug Hardware Real-time clock USB/ Ethernet/ Serial Overheads for Computers as Components