CS4101 嵌入式系統概論 RTOS and MQX Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan ( Materials from Freescale; Prof.

Slides:



Advertisements
Similar presentations
Chorus and other Microkernels Presented by: Jonathan Tanner and Brian Doyle Articles By: Jon Udell Peter D. Varhol Dick Pountain.
Advertisements

Computer Systems/Operating Systems - Class 8
Introduction to Operating Systems CS-2301 B-term Introduction to Operating Systems CS-2301, System Programming for Non-majors (Slides include materials.
Embedded & Real-time Operating Systems Peter Marwedel TU Dortmund, Informatik 12 Germany Graphics: © Alexandra Nolte, Gesine Marwedel, 2003 These slides.
Chapter 13 Embedded Systems
ECE 526 – Network Processing Systems Design Software-based Protocol Processing Chapter 7: D. E. Comer.
Operating Systems High Level View Chapter 1,2. Who is the User? End Users Application Programmers System Programmers Administrators.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
Embedded Real-time Systems The Linux kernel. The Operating System Kernel Resident in memory, privileged mode System calls offer general purpose services.
Chapter 13 Embedded Systems
Figure 1.1 Interaction between applications and the operating system.
Real-Time Kernels and Operating Systems. Operating System: Software that coordinates multiple tasks in processor, including peripheral interfacing Types.
Introduction Operating Systems’ Concepts and Structure Lecture 1 ~ Spring, 2008 ~ Spring, 2008TUCN. Operating Systems. Lecture 1.
1 Chapter 13 Embedded Systems Embedded Systems Characteristics of Embedded Operating Systems.
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
Copyright Arshi Khan1 System Programming Instructor Arshi Khan.
Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access memory.
CprE 458/558: Real-Time Systems (G. Manimaran)1 RTLinux Lab – Introduction Cpre 558 Anil
Performance Evaluation of Real-Time Operating Systems
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
Outline Introduction to MQX Initializing and starting MQX
UNIX System Administration OS Kernal Copyright 2002, Dr. Ken Hoganson All rights reserved. OS Kernel Concept Kernel or MicroKernel Concept: An OS architecture-design.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: System Structures.
Universität Dortmund Technische Universität Dortmund Embedded & Real-time Operating Systems Peter Marwedel TU Dortmund, Germany.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview Part 2: History (continued)
E X C E E D I N G E X P E C T A T I O N S OP SYS Linux System Administration Dr. Hoganson Kennesaw State University Operating Systems Functions of an operating.
Threads, SMP, and Microkernels Chapter 4. Process Resource ownership - process is allocated a virtual address space to hold the process image Scheduling/execution-
Embedded & Real-time Operating Systems Peter Marwedel TU Dortmund, Informatik 12 Germany 2012 年 11 月 27 日 These slides use Microsoft clip arts. Microsoft.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Chapter 1: Introduction and History  Where does the operating system fit in a computing system?  What does the operating system achieve?  What are the.
Threads G.Anuradha (Reference : William Stallings)
Processes Introduction to Operating Systems: Module 3.
LAB 12: Timer and Interrupt Chung-Ta King National Tsing Hua University CS 4101 Introduction to Embedded Systems.
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
- 1 -  P. Marwedel, Univ. Dortmund, Informatik 12, 05/06 Universität Dortmund Embedded operating systems - Requirement: Configurability - Configurability.
6.0 INTRODUCTION TO REAL-TIME OPERATING SYSTEMS (RTOS) 6.0 Introduction A more complex software architecture is needed to handle multiple tasks, coordination,
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Threads, SMP, and Microkernels Chapter 4. Processes and Threads Operating systems use processes for two purposes - Resource allocation and resource ownership.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
1 OPERATING SYSTEMS. 2 CONTENTS 1.What is an Operating System? 2.OS Functions 3.OS Services 4.Structure of OS 5.Evolution of OS.
Introduction to Operating Systems Concepts
MQX GPIO.
REAL-TIME OPERATING SYSTEMS
CS4101 Introduction to Embedded Systems Lab 8: Tower System
6.0 INTRODUCTION TO REAL-TIME OPERATING SYSTEMS (RTOS/RTK)
OPERATING SYSTEMS CS3502 Fall 2017
Process Management Presented By Aditya Gupta Assistant Professor
Introduction to Operating System
Introduction to Operating System (OS)
Real Time Operating System
Chapter 15, Exploring the Digital Domain
Mid Term review CSC345.
CS4101 嵌入式系統概論 RTOS Prof. Chung-Ta King Department of Computer Science
Memory Management Tasks
Chapter 8: Memory management
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
Lecture Topics: 11/1 General Operating System Concepts Processes
Lecture 4- Threads, SMP, and Microkernels
Threads Chapter 4.
Chapter 2: Operating-System Structures
Operating Systems Lecture 3.
EE 472 – Embedded Systems Dr. Shwetak Patel.
Outline Operating System Organization Operating System Examples
Chapter 2: Operating-System Structures
Embedded System Development Lecture 12 4/4/2007
Presentation transcript:

CS4101 嵌入式系統概論 RTOS and MQX Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan ( Materials from Freescale; Prof. P. Marwedel of Univ. Dortmund )

1 Recall Tower System Tower System MQX RTOS CodeWorrier IDE +

2 Outline  Introduction to embedded operating systems Comparison with desktop operating systems Characteristics of embedded operating systems  Introduction to real-time operating systems Requirements for an OS to be a real-time OS Classification of RTOS  Introduction to MQX and sample code

3 Operating Systems  The collection of software that manages a system’s hardware resources Often include a file system module, a GUI and other components  Often times, a “kernel” is understood to be a subset of such a collection  Characteristics Resource management Interface between application and hardware Library of functions for the application

4 Embedded Operating Systems  Fusion of the application and the OS to one unit  Characteristics: Resource management Primary internal resources Less overhead Code of the OS and the application mostly reside in ROM

5 Desktop vs Embedded OS  Desktop: applications are compiled separately from the OS  Embedded: application is compiled and linked together with the embedded OS On system start, application usually gets executed first, and it then starts the RTOS. Typically only part of RTOS (services, routines, or functions) needed to support the embedded application system are configured and linked in (Dr Jimmy To, EIE, POLYU)

6 Characteristics of Embedded OS  Configurability: No single OS fit all needs, no overhead for unused functions  configurability  Techniques for implementing configurability Simplest form: remove unused functions (by linker ?) Conditional compilation (using #if and #ifdef commands) Advanced compile-time evaluation and optimization Object-orientation specialized to a derived subclasses

7 Characteristics of Embedded OS  Device drivers often not integrated into kernel Embedded systems often application-specific  specific devices  move device out of OS to tasks For desktop OS, many devices are implicitly assumed to be presented, e.g., disk, network, audio, etc.  they need to be integrated to low-level SW stack Embedded OS Standard OS kernel

8 Characteristics of Embedded OS  Protection is often optional Embedded systems are typically designed for a single purpose, untested programs rarely loaded, and thus software is considered reliable Privileged I/O instructions not necessary and tasks can do their own I/O Example: Let switch be the address of some switch Simply use load register,switch instead of OS call

9 Characteristics of Embedded OS  Interrupts not restricted to OS Embedded programs can be considered to be tested Protection is not necessary Efficient control over a variety of devices is required  can let interrupts directly start or stop tasks (by storing task’s start address in the interrupt table)  more efficient than going through OS services But for standard OS: serious source of unreliability Reduced composability: if a task is connected to an interrupt, it may be difficult to add another task which also needs to be started by an event.

10 Characteristics of Embedded OS  Real-time capability Many embedded systems are real-time (RT) systems and, hence, the OS used in these systems must be real-time operating systems (RTOSs)  Features of a RTOS: Allows multi-tasking Scheduling of the tasks with priorities Synchronization of the resource access Inter-task communication Time predictable Interrupt handling

11 Outline  Introduction to embedded operating systems Comparison with desktop operating systems Characteristics of embedded operating systems  Introduction to real-time operating systems Requirements for an OS to be a real-time OS Classification of RTOS  Introduction to MQX and sample code

12 Requirements for RTOS  Predictability of timing The timing behavior of the OS must be predictable For all services of the OS, there is an upper bound on the execution time Scheduling policy must be deterministic The period during which interrupts are disabled must be short (to avoid unpredictable delays in the processing of critical events)

13 Requirements for RTOS  OS should manage timing and scheduling OS possibly has to be aware of task deadlines; (unless scheduling is done off-line). Frequently, the OS should provide precise time services with high resolution. Important if internal processing of the embedded system is linked to an absolute time in the physical environment  Speed: The OS must be fast

14 Functionality of RTOS Kernel  Processor management  Memory management  Timer management  Task management (resume, wait etc)  Inter-task communication and synchronization resource management

15 Why Use an RTOS?  Can use drivers that are available with an RTOS  Can focus on developing application code, not on creating or maintaining a scheduling system  Multi-thread support with synchronization  Portability of application code to other CPUs  Resource handling by RTOS  Add new features without affecting higher priority functions  Support for upper layer protocols such as: TCP/IP, USB, Flash Systems, Web Servers, CAN protocols, Embedded GUI, SSL, SNMP

16 Classification of RTOS  RT kernels vs modified kernels of standard OS Fast proprietary kernels: may be inadequate for complex systems, because they are designed to be fast rather than to be predictable in every respect, e.g., QNX, PDOS, VCOS, VTRX32, VxWORKS RT extensions to standard OS: RT-kernel runs all RT- tasks and standard-OS executed as one task on it  General RTOS vs RTOS for specific domains  Standard APIs vs proprietary APIs e.g. POSIX RT-Extension of Unix, ITRON, OSEK) Source: R. Gupta, UCSD

17 Ex.: RT-Linux  RT-tasks cannot use standard OS calls ( Hardware RT-Task RT-Linux RT-Scheduler Linux-Kernel driver scheduler Init BashMozilla interrupts I/O

18 Ex.: Posix RT-extensions to Linux  Standard scheduler can be replaced by POSIX scheduler implementing priorities for RT tasks Hardware Linux-Kernel driver POSIX 1.b scheduler Init BashMozilla I/O, interrupts RT-Task  Special RT-calls and standard OS calls available.  Easy programming, no guarantee for meeting deadline

19 Outline  Introduction to embedded operating systems Comparison with desktop operating systems Characteristics of embedded operating systems  Introduction to real-time operating systems Requirements for an OS to be a real-time OS Classification of RTOS  Introduction to MQX and sample code

20 What is MQX?  Multi-threaded, priority-based RTOS provides Task scheduling Task management Interrupt handling Task synchronization: mutexes, semaphores, events, messages Memory management IO subsystems Kernel logging

21 MQX Facilities Required Optional MQX, RTCS, etc are structured as a set of C files built by the user into a library that is linked into the same code space as the application. Libraries contain all functions but only called functions are included with the image.

22 MQX Tasks  Applications running on MQX are built around tasks  a system consists of multiple tasks Tasks take turns running Only one task is active (has the processor) at any given time MQX manages how the tasks share the processor (context switching)  Task context Data structure stored for each task, including registers and a list of owned resources

23 Hello World on MQX #include #define HELLO_TASK 5 /* Task IDs */ extern void hello_task(uint_32); const TASK_TEMPLATE_STRUCT MQX_template_list[] = { /* Task Index, Function, Stack, Priority, Name, Attributes, Parameters, Time Slice */ {HELLO_TASK, hello_task, 1500, 8, "hello", MQX_AUTO_START_TASK, 0, 0 }, { 0 } }; void hello_task(uint_32 initial_data){ printf("Hello World\n"); _task_block(); }

24 Hello World 2 on MQX (1/2) #include /* Task IDs */ #define HELLO_TASK 5 #define WORLD_TASK 6 extern void hello_task(uint_32); extern void world_task(uint_32); const TASK_TEMPLATE_STRUCT MQX_template_list[] = { /* Task Index, Function, Stack, Priority, Name, Attributes, Parameters, Time Slice */ {WORLD_TASK, world_task, 1000, 9, "world", MQX_AUTO_START_TASK, 0, 0}, {HELLO_TASK, hello_task, 1000, 8, "hello", 0,0,0}, { 0 } };

25 Hello World 2 on MQX (2/2) /* world_task:create hello_task & print " World " */ void world_task(uint_32 initial_data) { _task_id hello_task_id; hello_task_id = _task_create(0, HELLO_TASK, 0); if (hello_task_id == MQX_NULL_TASK_ID) { printf ("\n Could not create hello_task\n"); } else { printf(" World \n"); } _task_block(); } void hello_task(uint_32 initial_data) { printf("\n Hello\n"); _task_block(); }