180 likes | 317 Views
Embedded systems. William W. McMillan. 9 April 2013. What embedded systems existed in 1980? How many do you have on your person right now?. Kinds of Real-Time Operations. Monitor and record. Actuate (move, release ). Alarm, shut down, or take other emergency action. Control access.
E N D
Embedded systems William W. McMillan 9April 2013
What embedded systems existed in 1980?How many do you have on your person right now?
Kinds of Real-Time Operations • Monitor and record. • Actuate (move, release). • Alarm, shut down, or take other emergency action. • Control access. • Deliver content. • Communicate. • Translate, decode, or interpret.
Challenges of Real-Time • Small memory. • Slow processor. • Low power. • Need to be fast. • Deadlines need to be met. • Concurrent processes. • Need for reliability.
When have you programmed a real-time or embedded system? What challenges did you face?
Management Challenges • Programming language trade-offs. • Choosing hardware platform. • Choosing software platform. • Getting staff who know physics and electronics. • Deciding deployment. • Maintenance.
Decision Tables • “Stimulus-response” table. • E.g., if power low and buffer nearly full, write data in alternate storage. • Arrange by columns: • Condition, action. • Likely preliminary to state diagrams and are less formal.
State Diagrams • A principal tool for real-time systems. • Used in design, of course. • Critical for communicating how system works. • Need to keep up-to-date. • Use software tools to support.
Besides state diagrams, what other UML diagrams come to mind as useful for real-time and embedded systems?
Programming Practices • See reliability engineering. • Special premium on algorithm efficiency. • Memory is precious. • Pack data, e.g., bits for Booleans. • Use short representations when you can. • Need to control access. • Avoid dynamic memory allocation. • Protect stacks, etc. from overflow.
Programming Practices • Can have many “global” devices and data, e.g., • Ports. • Status bits. • Video memory. • Buffers. • Need much more discipline in accessing these. • Code inspection and formal analysis are useful.
Programming Practices • Data structures • Circular queue: • Producer prevented from adding to full queue. • Consumer prevented from taking from empty queue. • Pipeline: • Data handed from process to process. • General: hashing, logarithmic search, etc. • Timing analysis • Model processes to predict. • Based on finite state machines.
Think of a typical programming construct or method that would be inappropriate in many embedded systems.
Ways to Get Data and Status • Keep channels open • Switch-style, continuous communication. • Simplex or duplex. • Polling • Ask devices at regular intervals how things are going, if there are data, etc. • Interrupts • Device has low-level access to event loop. • Actively sends message when needs attention.
Scheduling (OS Issue) • Round robin • Each process gets a time unit in turn. • Priority queue • Most important goes first… • … but do the less important ever get a chance? • Multiple queues, by priority • Higher priority get less time. • As run more often, get more time, but lower priority.
Scheduling (OS Issue) • Shortest first • Run smaller jobs first. • Policy-driven, e.g., • If get less than share of CPU time, raise priority. • If impending deadline, raise priority. • If related to alarm, raise priority.
For a mobile device application, describe a policy for scheduling concurrent processes.
Sticky Wickets (OS Issues) • Deadlock, e.g., • ThreadAholds printer, waits for File1. • ThreadBholds File1, waits for printer. • Race condition, e.g., • ThreadA: if (x == y) • ThreadB: if (x == y) • ThreadA: { x++; } • ThreadB { x++; }