EE 472 Embedded Systems Dr Shwetak Patel Agenda
EE 472 – Embedded Systems Dr. Shwetak Patel
Agenda n n Lab 2 overview Operating System n n Tasks Threads Interrupts Scheduling Shwetak N. Patel - EE 472 2
Embedded Software n Execute a specialized program n Perform calculations n Access memory n Communicate with external devices Shwetak N. Patel - EE 472 3
Operating System n Makes your life easier! n Executes your code n Does memory management n Handles I/O and communications within your program Shwetak N. Patel - EE 472 4
An Embedded Program n Task n Unit of code n Think of it as a C function Shwetak N. Patel - EE 472 5
Scheduler n Part of the OS that execute the tasks so they all get a turn. n Make decisions about when to run the tasks Shwetak N. Patel - EE 472 6
Types of Tasks n Periodic n Found in hard-real time applications n Three attributes: n P, Period n C, Computing Resources n D, Deadline Shwetak N. Patel - EE 472 7
Types of Tasks n Intermittent n Found in all applications n Two attributes: n C, Computing Resources n D, Deadline Shwetak N. Patel - EE 472 8
Types of Tasks n Background n Soft-real time n Lower priority n One attribute: n C, Computing Resources Shwetak N. Patel - EE 472 9
Types of Tasks n Complex n Continuous need for CPU n Frequent requests for I/O n Wait for user input Shwetak N. Patel - EE 472 10
Multitasking n Multiple processes running in a program Shwetak N. Patel - EE 472 11
Task States n Ready n Running n Waiting (for something other than CPU) n n Preempted or blocked Inactive/Terminated Shwetak N. Patel - EE 472 12
Context Switch n A new task is switched in n Need to save the current context n Code n Data n Registers n Resources (memory, io, etc) Shwetak N. Patel - EE 472 13
Threads n Smaller unit of computation n Owned by a process n Like pieces within a process n Smaller context Shwetak N. Patel - EE 472 14
Threads n Example n Web server Shwetak N. Patel - EE 472 15
Processes and Threads Shwetak N. Patel - EE 472 16
Real-Time Operating System n Deterministic n Rigid time constraints Shwetak N. Patel - EE 472 17
Scheduler n Responsible for dispatching/executing tasks n When and how long to run a task n Scheduling strategies n Time sharing n Priorities Shwetak N. Patel - EE 472 18
Representing a Task n Task Control Block (TCB) n Contains information about a task n Think of a struct Shwetak N. Patel - EE 472 19
TCB
TCB
Task or Job Queue n Holds a collection of TCBs when a task enters a system n Array or list of structs Shwetak N. Patel - EE 472 22
Problems with this approach?
Problems with this approach? n Wastes time waiting for input n Need to use interrupts
Interrupts n External event n Causes a context switch n Each interrupt has a specific ID n Interrupts are found in a interrupt vector table
Interrupt Vector Table n Interrupt number n Interrupt service routines (ISR)
Questions? n Next time: n Scheduling algorithms n Print out scheduling worksheet Shwetak N. Patel - EE 472 29
- Slides: 29