Real Time and Embedded Systems. by Dr. Lesley Shannon Course Website:

Similar documents
Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Kernel Types Simple OS Examples System Calls. Operating Systems. Autumn CS4023

Software Design and Analysis for Engineers

Operating System Structure

Operating System Architecture. CS3026 Operating Systems Lecture 03

Operating System Structure

OS Design Approaches. Roadmap. OS Design Approaches. Tevfik Koşar. Operating System Design and Implementation

CSC Operating Systems Fall Lecture - II OS Structures. Tevfik Ko!ar. Louisiana State University. August 27 th, 2009.

Announcements. Computer System Organization. Roadmap. Major OS Components. Processes. Tevfik Ko!ar. CSC Operating Systems Fall 2009

BRDS ( , WS 2017) Ulrich Schmid

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

CSC Operating Systems Spring Lecture - II OS Structures. Tevfik Ko!ar. Louisiana State University. January 17 th, 2007.

Announcements. Operating System Structure. Roadmap. Operating System Structure. Multitasking Example. Tevfik Ko!ar

Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - II OS Structures. University at Buffalo. OS Design and Implementation

OS Design Approaches. Roadmap. System Calls. Tevfik Koşar. Operating System Design and Implementation. CSE 421/521 - Operating Systems Fall 2013

Introduction: Context Switch

Operating System Structure

Operating Systems. Operating System Structure. Lecture 2 Michael O Boyle

Microkernel Construction

Operating System. Operating System Overview. Structure of a Computer System. Structure of a Computer System. Structure of a Computer System

Operating-System Structures

EEE 435 Principles of Operating Systems

Process Description and Control

Operating System Kernels

Operating Systems Structure and Processes Lars Ailo Bongo Spring 2017 (using slides by Otto J. Anshus University of Tromsø/Oslo)

Software Design and Analysis for Engineers

Four Components of a Computer System

OS DESIGN PATTERNS II. CS124 Operating Systems Fall , Lecture 4

6.033 Spring Lecture #6. Monolithic kernels vs. Microkernels Virtual Machines spring 2018 Katrina LaCurts

1 System & Activities

Operating System Structure

Unit OS2: Operating System Principles. Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze

OS Structure. Kevin Webb Swarthmore College January 25, Relevant xkcd:

Agenda. Threads. Single and Multi-threaded Processes. What is Thread. CSCI 444/544 Operating Systems Fall 2008

Operating System Structure

! Software ( kernel ) that runs at all times. ! OS performs two unrelated functions: Maria Hybinette, UGA. user! 1! Maria Hybinette, UGA. user! n!

Arvind Krishnamurthy Spring Threads, synchronization, scheduling Virtual memory File systems Networking

Microkernel Construction. Introduction. Michael Hohmuth. Lars Reuther. TU Dresden Operating Systems Group

Chapter 2. Operating-System Structures

Chapter 2: Operating-System Structures. Operating System Concepts 9 th Edit9on

Threads. Thread Concept Multithreading Models User & Kernel Threads Pthreads Threads in Solaris, Linux, Windows. 2/13/11 CSE325 - Threads 1

W4118 Operating Systems. Junfeng Yang

CS533 Concepts of Operating Systems. Jonathan Walpole

CS 43: Computer Networks. 07: Concurrency and Non-blocking I/O Sep 17, 2018

CS 550 Operating Systems Spring Operating Systems Overview

Lecture Topics. Announcements. Today: Operating System Overview (Stallings, chapter , ) Next: Processes (Stallings, chapter

Processes and Threads

Real Time and Embedded Systems. by Dr. Lesley Shannon Course Website:

CSE 153 Design of Operating Systems Fall 2018

Overview of Operating Systems

System Call. Preview. System Call. System Call. System Call 9/7/2018

Case Study. Windows XP. Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze

OS and Computer Architecture. Chapter 3: Operating-System Structures. Common System Components. Process Management

Timers 1 / 46. Jiffies. Potent and Evil Magic

Operating Systems, Fall

The Performance of µ-kernel-based Systems

Operating Systems: Internals and Design Principles. Chapter 4 Threads Seventh Edition By William Stallings

Operating Systems Structure. Otto J. Anshus

Last Class: CPU Scheduling. Pre-emptive versus non-preemptive schedulers Goals for Scheduling: CS377: Operating Systems.

Master level: Operating systems, distributed systems, networking,

CPSC 341 OS & Networks. Introduction. Dr. Yingwu Zhu

Processes & Threads. Process Management. Managing Concurrency in Computer Systems. The Process. What s in a Process?

ELEC 377 Operating Systems. Week 1 Class 2

Rab Nawaz Khan Jadoon

CSCI 6730 / 4730 Operating Systems. Key Questions in System Design. Review: What is An Operating System? Key Points

4. Jump to *RA 4. StackGuard 5. Execute code 5. Instruction Set Randomization 6. Make system call 6. System call Randomization

Problem Set: Processes

Threads. Raju Pandey Department of Computer Sciences University of California, Davis Spring 2011

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

CSC 2405: Computer Systems II

Concurrent & Distributed Systems Supervision Exercises

What are some common categories of system calls? What are common ways of structuring an OS? What are the principles behind OS design and

Chapter 5: Synchronization 1

Lecture 5: Process Description and Control Multithreading Basics in Interprocess communication Introduction to multiprocessors

CSE 4/521 Introduction to Operating Systems

Operating Systems (2INC0) 2018/19. Introduction (01) Dr. Tanir Ozcelebi. Courtesy of Prof. Dr. Johan Lukkien. System Architecture and Networking Group

Architectural Support for Operating Systems. Jinkyu Jeong ( Computer Systems Laboratory Sungkyunkwan University

Operating-System Structures

For use by students enrolled in #71251 CSE430 Fall 2012 at Arizona State University. Do not use if not enrolled.

RESOURCE MANAGEMENT MICHAEL ROITZSCH

CHAPTER 2: PROCESS MANAGEMENT

Software Design and Analysis for Engineers

Overview of Operating Systems

Lecture 4: Memory Management & The Programming Interface

THREADS ADMINISTRIVIA RECAP ALTERNATIVE 2 EXERCISES PAPER READING MICHAEL ROITZSCH 2

OS Extensibility: SPIN and Exokernels. Robert Grimm New York University

Questions answered in this lecture: CS 537 Lecture 19 Threads and Cooperation. What s in a process? Organizing a Process

CSci 4061 Introduction to Operating Systems. (Thread-Basics)

Parallel Programming Models. Parallel Programming Models. Threads Model. Implementations 3/24/2014. Shared Memory Model (without threads)

Software Design and Analysis for Engineers

RESOURCE MANAGEMENT MICHAEL ROITZSCH

RESOURCE MANAGEMENT MICHAEL ROITZSCH

OS concepts and structure. q OS components & interconnects q Structuring OSs q Next time: Processes

Exokernel: An Operating System Architecture for Application Level Resource Management

CHAPTER 2: SYSTEM STRUCTURES. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

The OS Wars. Success

OPERATING SYSTEMS. UNIT II Sections A, B & D. An operating system executes a variety of programs:

Chapter 2: Operating-System Structures

CSE 4/521 Introduction to Operating Systems

Transcription:

Real Time and Embedded Systems by Dr. Lesley Shannon Email: lshannon@ensc.sfu.ca Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc351 Simon Fraser University Slide Set: 2 Date: September 13, 2011

Opening Thoughts Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Author Rick Cook, The Wizardry Compiled ENSC 351: Lecture Set 2 2

Slide Set Overview What is the Kernel? Microkernels and Monolithic kernels QNX Linux/PetaLinux ENSC 351: Lecture Set 2 3

The KERNEL ENSC 351: Lecture Set 2 4

The Kernel The kernel is the ENSC 351: Lecture Set 2 5

The Kernel Abstracts low-level system resources from applications Parts of the OS critical to its correct operation Operates in supervisor mode Everything else is in user mode Operates as trusted software: Intended to implement protection mechanisms that cannot be changed through actions of untrusted software Decides which thread runs ENSC 351: Lecture Set 2 6

The Kernel Starts the execution of the selected thread AKA switches context to the selected thread Context switching threads involves Saving the currently running thread s registers and other context information Loading the new thread s registers and context into the CPU What does the context switch remind you of? ENSC 351: Lecture Set 2 7

Context for Process/Thread Context Switches: Recall Context Switches for subroutines and interrupts Branch subroutine (ie bsr) Save PC and registers used on stack Interrupts (ie traps) Save PC, registers used, AND SR on stack ENSC 351: Lecture Set 2 8

The Kernel Keeps track of the state of all threads for thread scheduling Possible thread states: Running means the thread is actively running on the CPU Ready means that the thread could run right now ENSC 351: Lecture Set 2 9

The Kernel Possible Thread States (cont d): Blocked Thread is waiting for something to happen There are multiple reasons a thread can end up in a blocked state The kernel keeps track of why a thread can t run ENSC 351: Lecture Set 2 10

Types of Kernels ENSC 351: Lecture Set 2 11

Types of Kernels Monolithic kernels Linux, UNIX, MS-DOS Microkernels QNX, Mach, CHORUS, GNU/Hurd, L4 Windows NT was supposed to be, but not Other kernel types ENSC 351: Lecture Set 2 12

Monolithic Kernels The entire kernel is run in the kernel space in supervisor mode Uses a set of primitives or system calls to implement operating system services such as: process management, concurrency, and memory management all in kernel mode ENSC 351: Lecture Set 2 13

Monolithic Kernels The code integration is very tight and difficult to do correctly Since all the modules run in the same address space, a bug in one module can crash the whole system. When done well, the tight internal integration of components makes a good monolithic kernel highly efficient. ENSC 351: Lecture Set 2 14

Monolithic Kernel: The layers in a Linux System ENSC 351: Lecture Set 2 15

Monolithic Kernel: The Structure of the Linux Kernel ENSC 351: Lecture Set 2 16

Microkernels Provides no operating-system services at all (pure form) only the mechanisms needed to implement such services including: low-level address space management, thread management, and inter-process communication Designed to be Modular and Small ENSC 351: Lecture Set 2 17

Microkernels It is the only part of the system executing in kernel mode The actual operating-system services are provided by user mode servers including: device drivers, protocol stacks, file systems, and the user interface outside the kernel ENSC 351: Lecture Set 2 18

Microkernel Structure ENSC 351: Lecture Set 2 19

Other Kernels There are other kernels, but you don t need to worry about them If you are interested, check out: Hybrid Kernels Nanokernel Exokernel ENSC 351: Lecture Set 2 20

QNX ENSC 351: Lecture Set 2 21

QNX The higher-level OS functionality is provided by: A tiny kernel that provides minimal services A team of optional cooperating processes The QNX kernel does not have many typical OS services These are provided by optional processes ENSC 351: Lecture Set 2 22

QNX Optional system processes could include: Filesystem managers Character device managers Graphical user interface (Photon) Native network manager TCP/IP System processes are essentially the same as user-written applications ENSC 351: Lecture Set 2 23

QNX ENSC 351: Lecture Set 2 24

QNX The Kernel provides: Thread services via POSIX primitives Signal services via POSIX primitives Synchronization services via POSIX primitives ENSC 351: Lecture Set 2 25

QNX The Kernel provides (cont d): Timer services via POSIX Scheduling services via POSIX realtime scheduling algorithms Process management services Process manager + kernel = procnto Manages processes, memory, and pathname space ENSC 351: Lecture Set 2 26

QNX The Kernel provides (cont d): Message-passing services The kernel routes all messages between all threads in the system Inter-Process Communication (IPC) services Allows communication between all processes (application or device drivers) ENSC 351: Lecture Set 2 27

QNX Unlike threads, the kernel is never scheduled for execution The code in the kernel is only executed as the result of: an explicit kernel call, an exception, or a response to a hardware interrupt ENSC 351: Lecture Set 2 28

Linux/PetaLinux ENSC 351: Lecture Set 2 29

PetaLinux PetaLinux 2.1 implements a full Linux Kernel Version 2.6.37; updates include a device tree Therefore PetaLinux has many typical OS services Recall the Structure of the Linux Kernel ENSC 351: Lecture Set 2 30

Linux System processes include: Filesystem managers Character device managers Block device drivers Network Device Drivers TCP/IP protocols Can also include Loadable Kernel Modules (LKMs) Think Dynamically Loaded Libraries (DLLs) ENSC 351: Lecture Set 2 31

Linux/PetaLinux The PetaLinux Kernel provides: Thread services via POSIX primitives Signal services via POSIX primitives Synchronization services via POSIX primitives ENSC 351: Lecture Set 2 32

Linux/PetaLinux The PetaLinux Kernel provides (cont d): Timer services via POSIX Scheduling services via POSIX realtime scheduling algorithms Real-time FIFO; Real-time Round Robin; Timesharing Process management services & Memory Management services ENSC 351: Lecture Set 2 33

QNX The Kernel provides (cont d): Inter-Process Communication (IPC) services Allows Communication between all processes (application or device drivers) Message-passing services are supported via libraries Check out the Message Passing Interface (MPI) functions designed for C and Fortran-77 ENSC 351: Lecture Set 2 34

Questions? What type of kernel is the QNX kernel? What about Linux? Why would someone today still choose to use a monolithic kernel? ENSC 351: Lecture Set 2 35

Questions? What type of kernel should be used in Embedded and Real Time systems? Why? Recalling our discussion of processor architectures, why might a multi-threaded implementation of an application be slower than a single-threaded version? ENSC 351: Lecture Set 2 36

Question What additional information has to be saved for a thread context switch from that of a context switch between subroutines or a software interrupt? ENSC 351: Lecture Set 2 37

Real Time and Embedded Systems by Dr. Lesley Shannon Email: lshannon@ensc.sfu.ca Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc351 Simon Fraser University Slide Set: 2 Date: September 13, 2011

Monolithic Kernels Courtesy of Wikipedia ENSC 351: Lecture Set 2 39

Microkernels Courtesy of Wikipedia ENSC 351: Lecture Set 2 40

Kernel-level threads vs User-level Threads ENSC 351: Lecture Set 2 41

Kernel-level Threads Supported directly by the O/S The O/S has a separate thread for each process** Performs O/S activities on behalf of the O/S What is the name of this thread? [Hint: Recall the Collaboration graph Notation discussion] **At least- depends on the multi-threading model ENSC 351: Lecture Set 2 42

Kernel-level Threads Performs thread creation, scheduling and management in kernel space Thread management inside the kernel is generally slower that in user space i.e. Takes longer to create and manage kernel threads than user threads ENSC 351: Lecture Set 2 43

User-level Threads Run on top of the kernel Only exist within a process Cannot access a thread in a different process Isolation and modularity provide reliability Used by programmers to handle multiple flows of control within a process ENSC 351: Lecture Set 2 44

User-level Threads The kernel is unaware of user-level thread Implemented with a thread library Example? Supports creation and scheduling management outside of the kernel Done in user space without the kernel Generally fast to create and manage ENSC 351: Lecture Set 2