Lecture: Embedded Software Architectures

Similar documents
Tasks. Task Implementation and management

Department of Computer Science Institute for System Architecture, Operating Systems Group REAL-TIME MICHAEL ROITZSCH OVERVIEW

Introduction to Embedded Systems

Concurrent Programming

Concurrent Programming. Implementation Alternatives. Content. Real-Time Systems, Lecture 2. Historical Implementation Alternatives.

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

Embedded Software TI2725 C. 5. Software architectures. Koen Langendoen. Embedded Software Group

THREADS ADMINISTRIVIA RECAP ALTERNATIVE 2 EXERCISES PAPER READING MICHAEL ROITZSCH 2

Implementing Scheduling Algorithms. Real-Time and Embedded Systems (M) Lecture 9

Precept 2: Non-preemptive Scheduler. COS 318: Fall 2018

Introduction to Real-Time Operating Systems

CPSC/ECE 3220 Summer 2018 Exam 2 No Electronics.

Implementation Alternatives. Lecture 2: Implementation Alternatives & Concurrent Programming. Current Implementation Alternatives

OS 1 st Exam Name Solution St # (Q1) (19 points) True/False. Circle the appropriate choice (there are no trick questions).

Real-Time Programming

Lecture notes Lectures 1 through 5 (up through lecture 5 slide 63) Book Chapters 1-4

Introduction to Real-Time Systems and Multitasking. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Subject Name: OPERATING SYSTEMS. Subject Code: 10EC65. Prepared By: Kala H S and Remya R. Department: ECE. Date:

Multiprocessor and Real- Time Scheduling. Chapter 10

CS370 Operating Systems

Last Class: CPU Scheduling! Adjusting Priorities in MLFQ!

8: Scheduling. Scheduling. Mark Handley

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski

James E. Lumpp (Adapted from: An Embedded Software Primer by David E. Simon)

Threads and Too Much Milk! CS439: Principles of Computer Systems February 6, 2019

EECS 571 Principles of Real-Time Embedded Systems. Lecture Note #10: More on Scheduling and Introduction of Real-Time OS

Micrium µc/os II RTOS Introduction EE J. E. Lumpp

Scheduling. CS 161: Lecture 4 2/9/17

Back to RTOS. CSE466 Autumn 00-1


TDDB68 Processprogrammering och operativsystem / Concurrent programming and operating systems

Precept 3: Preemptive Scheduler. COS 318: Fall 2018

CS 326: Operating Systems. CPU Scheduling. Lecture 6

Threads and Too Much Milk! CS439: Principles of Computer Systems January 31, 2018

EE 472 Embedded Systems. Name solutions. Instructions:

Microkernel Construction

Microkernel/OS and Real-Time Scheduling

Midterm Exam. October 20th, Thursday NSC

Embedded Systems: OS. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Chapter 5: CPU Scheduling

Interrupts and Time. Real-Time Systems, Lecture 5. Martina Maggio 28 January Lund University, Department of Automatic Control

Last Class: Processes

Interrupts and Time. Interrupts. Content. Real-Time Systems, Lecture 5. External Communication. Interrupts. Interrupts

CPU Scheduling. CSE 2431: Introduction to Operating Systems Reading: Chapter 6, [OSC] (except Sections )

Embedded Systems: OS

EECS 482 Introduction to Operating Systems

Starting the Threads

CMPS 111 Spring 2013 Prof. Scott A. Brandt Midterm Examination May 6, Name: ID:

AC OB S. Multi-threaded FW framework (OS) for embedded ARM systems Torsten Jaekel, June 2014

CEC 450 Real-Time Systems

Verification of Real-Time Systems Resource Sharing

CSE 153 Design of Operating Systems Fall 2018

GLOSSARY. VisualDSP++ Kernel (VDK) User s Guide B-1

Chapter 5: Synchronization 1

Lecture 3. Introduction to Real-Time kernels. Real-Time Systems

Main Points of the Computer Organization and System Software Module

In Class Assignment 2

Exam TI2720-C/TI2725-C Embedded Software

Preview. Process Scheduler. Process Scheduling Algorithms for Batch System. Process Scheduling Algorithms for Interactive System

Midterm Exam Amy Murphy 6 March 2002

REAL-TIME OVERVIEW SO FAR MICHAEL ROITZSCH. talked about in-kernel building blocks:

Interrupts on the 6812

Please do not handin a.doc file, a.zip file, a.tar file, or anything else

Embedded Operating Systems

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads

SE300 SWE Practices. Lecture 10 Introduction to Event- Driven Architectures. Tuesday, March 17, Sam Siewert

SIDDHARTH GROUP OF INSTITUTIONS :: PUTTUR Siddharth Nagar, Narayanavanam Road QUESTION BANK (DESCRIPTIVE) UNIT I OPERATING SYSTEMS

Multitasking and scheduling

Process Synchronization

Problems Kernel Scheduler User Level Scheduler Universität Karlsruhe (TU), System Architecture Group

Operating Systems Comprehensive Exam. Spring Student ID # 3/20/2013

Process Coordination and Shared Data

CS370 Operating Systems

CS370 Operating Systems

1.1 CPU I/O Burst Cycle

CS370 Operating Systems

Preemptive Scheduling

Chapter 5: Process Synchronization. Operating System Concepts 9 th Edition

2. Introduction to Software for Embedded Systems

CISC 7310X. C05: CPU Scheduling. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/1/2018 CUNY Brooklyn College

Embedded System Curriculum

CS 167 Final Exam Solutions

COMP 3430 Robert Guderian

Schedulability with resource sharing. Priority inheritance protocol Priority ceiling protocol Stack resource policy

Operating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

Lecture Topics. Announcements. Today: Uniprocessor Scheduling (Stallings, chapter ) Next: Advanced Scheduling (Stallings, chapter

Concurrent activities in daily life. Real world exposed programs. Scheduling of programs. Tasks in engine system. Engine system

CS/ECE 6780/5780. Al Davis

Page 1. Lab 5 Logistics. Implicit Threads. Explicit Thread Semantics. Problem not enough interrupt pins CS/ECE 6780/5780. Al Davis

Lab 8 Real-time OS - 1

OS Structure. User mode/ kernel mode (Dual-Mode) Memory protection, privileged instructions. Definition, examples, how it works?

Student Name: University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science

CS418 Operating Systems

Reference Model and Scheduling Policies for Real-Time Systems

EECS 750: Advanced Operating Systems. 01/29 /2014 Heechul Yun

UNIT:2. Process Management

Operating Systems. Scheduling

CHESS: Analysis and Testing of Concurrent Programs

CS370 Operating Systems

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Transcription:

Lecture: Embedded Software Architectures Jan Vitek ECE/CS Spring 2011 Reading List 2 Mandatory Reading Chapter 5 of ECS textbook Optional Reading - N/A Software Architecture 3 A software architecture gives the general structure of an embedded application independent of the actual computation performed Choice of architecture impacts issues such as: development time / likelihood of software defects responsiveness and latency code size / complexity Rule of thumb: Select simplest architecture that meets application requirements Any extraneous complexity/generality costs additional development and verification effort

Software Architectures 4 Four well known choices: Simple Round Robin Round Robin with Interrupts Round Robin with Interrupts and Function Queues Real-time Operating System-based architectures The architectures are sorted in order of increasing complexity Round Robin (RR) architectures are also called Cyclic Executives in real-time literature The main different between RR and RTOS-based approaches is that in RR scheduling and admission control is done by the developer as opposed to leaving it to the OS Round Robin 5 Simplest architecture, a single loop checks devices in predefined sequence and performs I/O right away 1. while(1) { 2. if (device_1_ready()) { /*Perform D1 I/O and relate computation.*/ } 3. if (device_2_ready()) { /*Perform D2 I/O and relate computation.*/ } 4. 5. if (device_n_ready()) { /*Perform DN I/O and relate computation.*/ } 6. } Works well for system with few devices, trivial timing constraints, proportionally small processing costs Response time of device i equal to WCET of the body of the loop Round Robin 6 Periodic Round Robin In case the system must perform operations at different frequencies Add code to wait a variable amount of time 1.while(1) { 2. waitfornextperiod(10); // idle for up to 10 ms 3. if (device_1_ready()) { /*Perform D1 I/O and relate computation.*/ } 4.... Exercise: Think of how to implement a loop that runs every 10 ms and measures the drift

Round Robin 7 Limitations of the architecture: If some devices require small response times, while other have large WCET it will not be possible to guarantee that all timing constraints will be met The architecture is fragile, adding a new task can easily cause missed deadlines Question: - Is the order in which devices appear significant? - Same question, but with code for devices having different processing times and timing constraints? Round Robin with Interrupts 8 Hardware events requiring small response times handled by ISRs Typically ISRs do little more than set flags and copy data 1. bool f_device_1 = FALSE; 2. bool f_device_1 = FALSE; 3. 4. void interrupt handle_dev_1() { 5. // handle device 1 6. f_device_1 = TRUE; 7. } 8. 9. void main() { 10. while (1) { 11. if(f_device_1) { 12. f_device_1 = FALSE; 13. // do processing related to device 1 14. if (f_device_2) { 15. 16. } 17.} Round Robin with Interrupts 9 Latency of an ISR is function of response time of higher ISRs Lower bound on latency of RR loop is response time of the ISRs high low All code RR Device 1 ISR Device 2 ISR Device 3 ISR All task code RR with I

Round Robin with Interrupts 10 Drawbacks All task code executes at same - One can test some flags multiples times within loop body to reduce latency Shared data bugs Question: - What if one of the device requires large amount of processing time (larger than the time constraint of others?) RR+I and Function Queues 11 Rather than fixed order, program manages order of execution 1. #define DEV_1 1 2. #define DEV_2 2 3. 4. void interrupt handle_dev_1() { 5. // deal with device 6. enqueue(dev_1); 7. } 8. 9. void main() { 10. while (1) { 11. switch (dequeue()) { 12. case DEV_1: // process DEV_1 13. break; 14. 15. default: // empty queue nothing to do 16. } 17. } 18.} RR+I and Function Queues 12 One could use function pointers, but they add complexity FP are useful if one does not want to hardwire the devices in the main loop enqueue() reorders queue to improve latency of high devices For long running functions: break them up into multiple smaller units Question: does that improve latency? Question Consider implementation of dequeue(), what kind of data structure would you use (why), is special care needed?

Real-time Operating Systems 13 Rely on the operating for scheduling tasks Leverage preemptive scheduling to ensure that deadlines are met 1. static pthread_t thread_1; 2. 3. void interrupt handle_dev_1() { 4. // handle device 5. CHECK( pthread_wakeup(thread_1) ); 6. } 7. 8. void task_1() { 9. while (1) { 10. pthread_suspend_np(); 11. // process device 1 I/O 12. } 13. } 14. Real-time Operating Systems 14 The scheduler in a RTOS takes care of scheduling all tasks according to their Long running, low, tasks can be preempted by higher ones high Device 1 ISR Device 1 ISR Device 2 ISR Device 2 ISR Device 3 ISR Device 3 ISR All code All task code Task 1 low RR RR with I Task 2 RTOS Real-time Operating Systems 15 Services that an RTOS could provide: Scheduling tasks - create/terminate threads - timing threads operations - preemption Synchronization - semaphores and locks Input/Output - interrupt handling Memory management - separate stacks - segmentation - allocation/deallocation File system - persistent store Security - user vs. kernel space - identity management

Conclusion 16 Software architectures describe the structure of a system independently of its function Round Robin is a simple architecture for devices with few (or uniform) timing constraints Round Robin with Interrupts extends RR with low-latency interrupt handling Round Robin with Interrupts and Function Queues allows dynamic scheduling of tasks under programmatic control Real-time Operating Systems relieve programmers from having to deal with scheduling and time management