Top Banner
14

Embedded Operating System Design October 4, 2012 Doug Kelly.

Dec 25, 2015

Download

Documents

Gillian Booth
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Embedded Operating System Design October 4, 2012 Doug Kelly.
Page 2: Embedded Operating System Design October 4, 2012 Doug Kelly.

Embedded Operating System DesignOctober 4, 2012

Doug Kelly

Page 3: Embedded Operating System Design October 4, 2012 Doug Kelly.

Embedded Platforms

What’s different?• System-on-Chip (SoC) integrates components• Storage (MNAND, NOR, SD…)• Power requirements/management• May have memory management (MMU)• May have graphics processor (GPU)• May have direct memory access (DMA)• More specialized hardware

• Digital signal processor (DSP)• GPS baseband processor• Camera/imaging processor

Page 4: Embedded Operating System Design October 4, 2012 Doug Kelly.

Embedded Platforms - Processors

• ARM, MIPS, RISC…?• ARM is RISC-based, sold as IP “blocks”

• Core processor• Debugging coprocessor• GPU block (Mali), or 3rd-party vendors (SGX, Tegra)• Vector Floating Point (VFP)• NEON (SIMD processing architecture)• Memory management• Cache memory

• 32-bit architecture• Three instruction sets (ARM, Thumb, Thumb2)

Page 5: Embedded Operating System Design October 4, 2012 Doug Kelly.

Embedded Platforms

• Okay, so what?• Floating point is not free.• Time-critical tasks need servicing• Other devices may be using memory bus• May only have physical addressing• Storage is slow, cache is limited

• Engineers need to solve this!

Page 6: Embedded Operating System Design October 4, 2012 Doug Kelly.

Operating System Design

• Emebedded OSes exist!• Home-grown, open-source or commercial

• GarminOS• WindowsCE (Windows Embedded Compact)• VxWorks• QNX• Linux (RTLinux)• eCos

• Handle scheduling by priority or round-robin• WinCE has 256 process priorities (8 for applications) and

round-robin scheduling within a priority

Page 7: Embedded Operating System Design October 4, 2012 Doug Kelly.

Operating System Design - Memory

• RTOSes handle memory management• Some platforms don’t have MMUs, now what?

• May not be possible to use dynamic memory• Safest, most portable option.• Relies on static structures within program to use as

scratch space

• Design a malloc() replacement?• Need to mark memory in-use, so it isn’t used while

defragging memory• Pointer to allocated memory may change, so requires

careful design

Page 8: Embedded Operating System Design October 4, 2012 Doug Kelly.

Operating System Design - Scheduling

• Threads can be used to limit impact of non-critical failures in some applications

• Priority systems guarantee most critical tasks run when needed• Lower priority tasks run when higher tasks are blocked in

some form (may be waiting for next event)

• But… higher priority tasks could be blocked if a lower-priority task holds a resource!

Page 9: Embedded Operating System Design October 4, 2012 Doug Kelly.

Operating System Design - Scheduling

• Priority “inversion” temporarily raises priority• Allows low-priority tasks to finish faster, unblocking high-

priority tasks

• Control your loops/recursion!• Some coding guidelines for embedded systems prohibit

recursion, since it can quickly go without bound or exceed stack space.

• A high priority task stuck in a runaway loop can result in an unresponsive or useless system.

• Watch for deadlocks!• True in any OS, but may be catastrophic in some cases• Some RTOSes can detect deadlocks• Always reserve resources in the same order

Page 10: Embedded Operating System Design October 4, 2012 Doug Kelly.

Operating System Design - Interrupts

• IRQ, FIQ• Come in many flavors

• Hardware• External peripherals• DMA

• Timers• Special-purpose hardware interrupt• Service watchdog timers, handle rescheduling, sometimes

communication

• Software• When good software goes bad• “Data Abort” – illegal memory access, page faults (if supported)• “Pre-fetch Abort”• “Undefined Instruction”• Division by zero, etc.

Page 11: Embedded Operating System Design October 4, 2012 Doug Kelly.

Operating System Design - Interrupts

• ISRs used to handle interrupts• ISRs may have limitations imposed by OS,

platform, or processor technology• Timing constraints• Access to memory• IRQ may be interrupted• Must not block!

• Handling dependent on the interrupt vector table• Defines both exception and IRQ/FIQ handlers

• Fast and efficient is the key!

Page 12: Embedded Operating System Design October 4, 2012 Doug Kelly.

Operating System Design - IPC

• Inter-process communication used to interact with the system at all levels• Hardware drivers have no business updating UI state,

nor should UI touch hardware

• Can also be used to process long-running jobs• May be simple events, or contain data

• Who owns the data?• Which thread is the event processed on?• When is the event processed?

• Callback functions to return control• Boost signals/slots

• Object-Oriented Callbacks

Page 13: Embedded Operating System Design October 4, 2012 Doug Kelly.

Debugging

• JTAG• Closest to processor, can access entire memory bus• May be useful for saving snapshot of device state for

future analysis.• Can also load code into RAM and reset registers (but

peripherals may not reset!)

• WinCE: KITL• Kernel level transport, has a fair-amount of control• Allows developer to see “into” kernel calls• WinCE also supports Visual Studio Remote Debugging

• Linux/Other: GDB• Can be implemented on many platforms; gdb has stubs

• Don’t rule out printf()!

Page 14: Embedded Operating System Design October 4, 2012 Doug Kelly.

Doug KellySoftware Engineer

[email protected]

Questions?