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

Similar documents
Operating Systems Structure. Otto J. Anshus

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Processes and Threads

Process Time. Steven M. Bellovin January 25,

Preemptive Scheduling and Mutual Exclusion with Hardware Support

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

5 Lecture: Intro. to Concurrency

Announcement. Exercise #2 will be out today. Due date is next Monday

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

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

Why use an Operating System? Operating System Definition

Lecture 4: Memory Management & The Programming Interface

Operating System Architecture. CS3026 Operating Systems Lecture 03

Computer Systems II. First Two Major Computer System Evolution Steps

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

COS 318: Operating Systems

Processes Prof. James L. Frankel Harvard University. Version of 6:16 PM 10-Feb-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved.

COS 318: Operating Systems

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

Process Description and Control

CSCE Introduction to Computer Systems Spring 2019

Operating Systems, Fall

Master level: Operating systems, distributed systems, networking,

W4118 Operating Systems. Junfeng Yang

What is an Operating System? A Whirlwind Tour of Operating Systems. How did OS evolve? How did OS evolve?

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

Process Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey

Reserves time on a paper sign-up sheet. Programmer runs his own program. Relays or vacuum tube hardware. Plug board or punch card input.

3.1 Introduction. Computers perform operations concurrently

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

Chapter 4: Threads. Operating System Concepts 8 th Edition,

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

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

Lecture Topics. Announcements. Today: Threads (Stallings, chapter , 4.6) Next: Concurrency (Stallings, chapter , 5.

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

Lecture 2 Fundamental OS Concepts. Bo 2018, Spring

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

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

Protection and System Calls. Otto J. Anshus

CS 326: Operating Systems. Process Execution. Lecture 5

references Virtualization services Topics Virtualization

Introduction: Context Switch

Operating Systems Overview. Chapter 2

Threads. Computer Systems. 5/12/2009 cse threads Perkins, DW Johnson and University of Washington 1

What s in a process?

Processes. Process Management Chapter 3. When does a process gets created? When does a process gets terminated?

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4

Implementation of Processes

Introduction to Concurrency (Processes, Threads, Interrupts, etc.)

Processes & Threads. Recap of the Last Class. Layered Structure. Virtual Machines. CS 256/456 Dept. of Computer Science, University of Rochester

Processes and Threads Implementation

Processes and More. CSCI 315 Operating Systems Design Department of Computer Science

Threads and Critical Sections. Otto J. Anshus, Thomas Plagemann, Tore Brox-Larsen, Kai Li

Distributed Systems Operation System Support

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

Overview of Operating Systems

Processes and Threads. Processes and Threads. Processes (2) Processes (1)

Introduction to Operating Systems

Operating System Kernels

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

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

Processes and Threads

Processes. Dr. Yingwu Zhu

Unit 2 : Computer and Operating System Structure

OS structure. Process management. Major OS components. CSE 451: Operating Systems Spring Module 3 Operating System Components and Structure

Multiprogramming. Evolution of OS. Today. Comp 104: Operating Systems Concepts 28/01/2013. Processes Management Scheduling & Resource Allocation

Part V. Process Management. Sadeghi, Cubaleska RUB Course Operating System Security Memory Management and Protection

Lecture 4: Threads; weaving control flow

Process Description and Control

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Computer Systems Engineering: Spring Quiz I Solutions

What s in a traditional process? Concurrency/Parallelism. What s needed? CSE 451: Operating Systems Autumn 2012

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

Virtual machines are an interesting extension of the virtual-memory concept: not only do we give processes the illusion that they have all of memory

Role 1: The Operating System is an Abstract Machine. Learning Outcomes. Introduction to Operating Systems. What is an Operating System?

CSE 153 Design of Operating Systems Fall 2018

csci3411: Operating Systems

Part I Introduction Hardware and OS Review

KERNEL THREAD IMPLEMENTATION DETAILS. CS124 Operating Systems Winter , Lecture 9

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

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

Learning Outcomes. Processes and Threads. Major Requirements of an Operating System. Processes and Threads

Background: Operating Systems

CPSC/ECE 3220 Fall 2017 Exam Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts.

CSC 4320 Test 1 Spring 2017

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

10/10/ Gribble, Lazowska, Levy, Zahorjan 2. 10/10/ Gribble, Lazowska, Levy, Zahorjan 4

1 System & Activities

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

Processes. CS 416: Operating Systems Design, Spring 2011 Department of Computer Science Rutgers University

Announcements Processes: Part II. Operating Systems. Autumn CS4023

ELEC 377 Operating Systems. Week 1 Class 2

CSE 4/521 Introduction to Operating Systems. Lecture 29 Windows 7 (History, Design Principles, System Components, Programmer Interface) Summer 2018

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

Computer System Overview

Operating System. Operating Systems Structure Chapter 2. Services Provided by the OS. Evolution of an Operating System

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

CS 5523: Operating Systems

Processes (Intro) Yannis Smaragdakis, U. Athens

Rab Nawaz Khan Jadoon

Transcription:

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

The Architecture of an OS Monolithic Layered Virtual Machine, Library, Exokernel Micro kernel and Client/Server Hybrids 21.01.16 INF-2201, Tore Brox-Larsen 2

Goals of the architecture OS as Resource Manager OS as Virtual Machine (abstractions) Efficiency, flexibility, size, security, as discussed earlier 21.01.16 INF-2201, Tore Brox-Larsen 3

Operating System Use of Processes: Where is the OS executing? Separate Kernel Illustrations: Stallings: Operating System: Internals and Design P 1 P 2 P 3 P 4 P 5 P n Kernel 21.01.16 INF-2201, Tore Brox-Larsen 4

OS-Functions Executing within Processes P 1 P 2 P 3 P 4 P 5 P n OS- Funct ions OS- Funct ions OS- Funct ions OS- Funct ions OS- Funct ions OS- Funct ions Process Switching 21.01.16 INF-2201, Tore Brox-Larsen 5

OS-Functions Executing in Separate Processes P 1 P 2 P 3 P 4 P 5 OS 1 OS 2 OS n Process Switching 21.01.16 INF-2201, Tore Brox-Larsen 6

User process Service Service Service Service Interrupt handler: Start requested service Operating System Kernel Start (next?) user program Services Interrupt Hardware 21.01.16 Data from network Overhead UL -> KL UL address space -> UL addr. space

Monolithic All kernel routines are together A system call interface Examples: Linux Most Unix OS NT (hybrid) User program entry User program Kernel many many things 21.01.16 INF-2201, Tore Brox-Larsen 8

Layered Structure Hiding information at each layer Develop a layer at a time Examples Level N. Level 2 THE (6 layers, semaphores, Dijkstra Level 1 1968) MS-DOS (4 layers) Hardware 21.01.16 INF-2201, Tore Brox-Larsen 9

Microkernel and Client/Server Micro-kernel is micro Services are implemented as user level processes Micro-kernel get services on behalf of users by messaging with the service processes Example: L4, Nucleus, Taos, Mach, Mach, NT (hybrid) User program entry m-kernel Services 21.01.16 INF-2201, Tore Brox-Larsen 10

Virtual Machine "A running program is often referred to as a virtual machine - a machine that doesn't exist as a matter of actual physical reality. The virtual machine idea is itself one of the most elegant in the history of technology and is a crucial step in the evolution of ideas about software. To come up with it, scientists and technologists had to recognize that a computer running a program isn't merely a washer doing laundry. A washer is a washer whatever clothes you put inside, but when you put a new program in a computer, it becomes a new machine... The virtual machine: A way of understanding software that frees us to think of software design as machine design." From David Gelernter's "Truth, Beauty, and the Virtual Machine," Discover Magazine, September 1997, p. 72. 21.01.16 INF-2201, Tore Brox-Larsen 11

Virtual machine monitor provide multiple virtual real hardware run different OS codes Example IBM VM/370: Started in the 70 s. Check out virtual 8086 mode Java VM VMware Exokernel Virtual Machine User Mode user OS 1 VM 1 Small kernel Bare hardware VM n Exact copies of 21.01.16 the bare hardware 12... Virtual Kernel Mode user OS n Virtual User Mode Syscall trapped Privileged instructions trapped Kernel Mode

21.01.16 INF-2201, Tore Brox-Larsen 13

Virtual 8086 21.01.16 INF-2201, Tore Brox-Larsen 14

Java VM Ref. Pascal P-Code 21.01.16 INF-2201, Tore Brox-Larsen 15

21.01.16 INF-2201, Tore Brox-Larsen 16

Hardware Support What is the minimal support? 2 modes Exception and interrupt trapping Can virtual machine be protected without such support? Yes, emulation instead of executing on real machine 21.01.16 INF-2201, Tore Brox-Larsen 17

Pro et Contra Monolithic Layered VM C/S Micro kernel Performance Clean, less bugs Clear division of labour Many virtual computers with different OS es Test of new OS while production work continues All in all: flexibility Clear division of labour More flexible Small means less bugs+manageable Distributed systems Failure isolation of services at Kernel Level Less structured Are layers really sepaparated? Performance issues? Performance issues? Complexity issues? Performance issues? Flexibility issues? Performance issues? 21.01.16 INF-2201, Tore Brox-Larsen 18

Truths on Micro Kernel Flexibility and Performance A micro kernel restricts application level flexibility. Switching overhead kernel-user mode is inherently expensive. Switching address-spaces is costly. IPC is expensive. Micro kernel architectures lead to memory system degradation. Kernel should be portable (on top of a small hardwaredependent layer). NO: Can be <50 cycles NO: 6-20 microsec round-trip, 53-500 cycles/ipc one way 21.01.16 Taken from Jochen Liedtke, SOSP 15 paper: On micro kernel construction

Problem to solve Concurrency and Process A shared CPU, many I/O devices and lots of interrupts Users feel they have machine to themselves Strategy Decompose hard problems into simple ones Deal with one at a time Process is such a unit 21.01.16 INF-2201, Tore Brox-Larsen 20

Flow of Execution P1: Input syscall Trap handling; Scheduler; Dispatch; Int0x80 (Assume R to disk => long wait 10-100 s ms) Kernel Mode User Mode P2: CPU bound Trap handling; Scheduler; Dispatch; Input finished interrupt (Could have started another process than P1) P1: CPU bound Timer 10-100ms Trap handling; Scheduler; Dispatch; 21.01.16 21

Procedure, Co-routine, Thread, Process Procedure, Function, (Sub)Routine Call-execute all-return nesting Co-routine Call-resumes-return Thread (more later) Process Single threaded Multi threaded User level non preemptive scheduler in user code 21.01.16 INF-2201, Tore Brox-Larsen 22

Procedure and Co-routine Main A B 1 Call A; Call B; User Yield when finished Call B; 2 1 2 Return Return Main A B Call A; Call B; Resume A; User Yield during execution to share CPU Resume B; Resume A; Never executed Return 21.01.16 23

Process Sequential execution of operations No concurrency inside a (single threaded) process Everything happens sequentially Process state Registers Stack(s) Main memory Open files in UNIX Communication ports Other resources 21.01.16 INF-2201, Tore Brox-Larsen 24

Program and Process For at least one thread of execution main() {... foo()... } foo() {... } Program main() {... foo()... } foo() {... } Process PID heap stack main foo registers PC Resources: comm. ports, files, semaphores The context 21.01.16 25

Process vs. Program Process > program Program is just part of process state Example: many users can run the same program Process < program A program can invoke more than one process Example: Fork off processes to lookup webster 21.01.16 INF-2201, Tore Brox-Larsen 26

Instruction Pointer (program counter) in the EIP register U s e r L e v e l P r o c e s s e s Trap Handler Trap Return Handler P1 Process State Transitions P2 Service BlockedQueue P3 P2 P4 KERNEL MULTIPROGRAMMING Uniprocessor: Interleaving ( pseudoparallelism ) Multiprocessor: Overlapping ( true paralellism ) Scheduler ReadyQueue P3 P4 terminate Dispatcher Current P1 PCB s Running Memory resident part Create a process Ready Blocked Resource becomes 21.01.16 INF-2201, Tore Brox-Larsen available 27

Process State Transition Running terminate Create a process Ready Blocked Resource becomes available 21.01.16 INF-2201, Tore Brox-Larsen 28

What Process Control Block (Process Table) Process management info State (ready, running, blocked) Registers, PSW, parents, etc Memory management info Segments, page table, stats, etc I/O and file management Communication ports, directories, file descriptors, etc. 21.01.16 INF-2201, Tore Brox-Larsen 29

Discussion: What needs to be saved and restored on a context switch? Volatile state Program counter (Program Counter (PC) also called Instruction Pointer (Intel: EIP)) Processor status register Other register contents User and kernel stack pointers A pointer to the address space in which the process runs the process s page table directory 21.01.16 INF-2201, Tore Brox-Larsen 30

and how? Save(volatile machine state, current process); Load(another process s saved volatile state); Start(new process); 21.01.16 INF-2201, Tore Brox-Larsen 31

Trad. Threads Threads and Processes Project OpSys Process Processes in individual address spaces Threads Kernel Address Space Kernel threads User Level 21.01.16 Kernel Level

Some Links Virtual machine https://en.wikipedia.org/wiki/virtual_machine Exokernel https://pdos.lcs.mit.edu/archive/exo/docs.html THE http://www.cs.utexas.edu/users/ewd/ewd01xx/ewd196.pdf L4 http://os.inf.tu-dresden.de/l4/overview.html VM http://www.vm.ibm.com/ 21.01.16 INF-2201, Tore Brox-Larsen 33