Operating System: Chap2 OS Structure. National Tsing-Hua University 2016, Fall Semester

Similar documents
Chapter 2: Operating-System Structures

Chapter 2: Operating-System Structures

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

Chapter 2: Operating-System Structures. Operating System Concepts Essentials 8 th Edition

Chapter 2: Operating-System

Chapter 2: Operating-System Structures

Chapter 2: Operating-System Structures. Chapter 2: Operating-System Structures. Objectives. Operating System Services

Lecture 2 Operating System Structures (chapter 2)

Objectives. Chapter 2: Operating-System Structures. 2.1 Operating System Services

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

Operating-System Structures

Operating-System Structures

TDDI04, K. Arvidsson, IDA, Linköpings universitet Operating System Structures. Operating System Structures Overview. Operating System Services

Chapter 2: System Structures

Chapter 2: Operating-System Structures. Operating System Concepts 8 th Edition

CS307: Operating Systems

The Slide does not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams.

Operating System Structure

Chapter 2: Operating-System Structures

Operating System Services

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Chapter 3: Operating-System Structures

Chapter 2. Operating-System Structures

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

Chapter 3: Operating-System Structures

Chapter 2 Operating System Structures

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

Last class: OS and Architecture. OS and Computer Architecture

Last class: OS and Architecture. Chapter 3: Operating-System Structures. OS and Computer Architecture. Common System Components

Chapter 2: OS Structures

Chapter 3: Operating-System Structures

Chapter 2. Operating System Structures

Chapter 2: Operating-System Structures

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

Lecture 2 - Fundamental Concepts

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

Operating System Structure

Chapter 2: System Structures. Operating System Concepts 9 th Edition

Operating System Services. User Services. System Operation Services. User Operating System Interface - CLI. A View of Operating System Services

Chapter 2: System Structures

Operating System Structure

Chapter 2 Operating-System Structures

Operating-System Structures

NON SCHOLAE, SED VITAE

CS420: Operating Systems. OS Services & System Calls

Introduction to Operating Systems (Part III)

Operating System Architecture. CS3026 Operating Systems Lecture 03

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

Often, more information is required when designing system call Information varies according to OS and types of system call

Chapter 2: System Structures. Operating System Concepts 9 th Edition

Four Components of a Computer System

CSE 4/521 Introduction to Operating Systems

OPERATING SYSTEMS Lecture Notes. Prepared by K.Rohini, Assistant Professor, CSE Department, GVPCEW.

CS370 Operating Systems

Module 3: Operating-System Structures. Common System Components

OPERATING SYSTEMS UNIT - 1

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

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

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

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

Chapter 3 Process Description and Control

Operating- System Structures

Operating System: Chap13 I/O Systems. National Tsing-Hua University 2016, Fall Semester

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

CSE Opera+ng System Principles

What we saw. Desarrollo de Aplicaciones en Red. 1. OS Design. 2. Service description. 1.1 Operating System Service (1)

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

What does an Operating System do?

TDDB68 Concurrent Programming and Operating Systems. Lecture 1: Introduction, interrupts and system calls

Module 3: Operating-System Structures

OPERATING SYSTEMS. Prescribed Text Book Operating System Principles, Seventh Edition By Abraham Silberschatz, Peter Baer Galvin and Greg Gagne

Full file at

CHAPTER 16 - VIRTUAL MACHINES

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

UNIT 2. OPERATING SYSTEM STRUCTURES

CS 390 Chapter 2 Homework Solutions

Module 1 Introduction/OS Overview

ELEC 377 Operating Systems. Week 1 Class 2

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - VII CPU Scheduling - II. Louisiana State University

Roadmap. Multilevel Queue Scheduling. Multilevel Queue. Example of Multilevel Feedback Queue. Multilevel Feedback Queue. Tevfik Ko!

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

COS 318: Operating Systems

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

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

CS420: Operating Systems

Operating Systems 2010/2011

Chap2: Operating-System Structures

Operating Systems CS3502 Spring 2018

Operating-System Structures

OPERATING SYSTEM OVERVIEW

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed

CS 300 Leftovers. CS460 Pacific University 1

Chapter 2: Operating-System Structures

Learning Outcomes. Extended OS. Observations Operating systems provide well defined interfaces. Virtual Machines. Interface Levels

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

Process Description and Control

OS Structures. ICS332 Operating Systems

Transcription:

Operating System: Chap2 OS Structure National Tsing-Hua University 2016, Fall Semester

Outline OS Services OS-Application Interface OS Structure Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 2

OS Services Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 3

OS services User interface Program Execution I/O operations File-system manipulation Communication Error detection Resource allocation Accounting Protection and security Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 4

OS services User interface Program Execution I/O operations File-system manipulation Communication Error detection Resource allocation Accounting Protection and security ensuring the efficient operation of the system itself Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 5

OS services User interface Program Execution I/O operations File-system manipulation Communication Error detection Resource allocation Accounting Protection and security ensuring the efficient operation of the system itself Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 6

User Interface CLI (Command Line Interface) Fetches a command from user and executes it Shell: Command-line interpreter (CSHELL, BASH) Adjusted according to user behavior and preference GUI (Graphic User Interface) Usually mouse, keyboard, and monitor Icons represent files, programs, actions, etc Various mouse buttons over objects in the interface cause various actions Most systems have both CLI and GUI Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 7

Communication Models Communication may take place using either message passing or shared memory. Msg Passing Shared Memory Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 8

Applications-OS Interface System calls API Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 9

System Calls Request OS services Process control abort, create, terminate process allocate/free memory File management create, delete, open, close file Device management read, write, reposition device Information maintenance get time or date Communications send receive message Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 10

System Calls & API System calls The OS interface to a running program An explicit request to the kernel made via a software interrupt Generally available as assembly-language instructions API: Application Program Interface Users mostly program against API instead of system call Commonly implemented by language libraries, e.g., C Library An API call could involve zero or multiple system call Both malloc() and free() use system call brk() Math API functions, such as abs(), don t need to involve system call Application Program Interface C Library (libc) System Calls (Assembly language) /usr/src/linux/arch/i386/kernel/entry.s OS Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 11

Interface vs. Library User program: printf( %d, exp2(int x, int y)); Interface: int exp2(int x, int y); i.e. return the value of X 2 y Library: Imp1: int exp2(int x, int y) { for (int i=0; i<y; i++) x=x*2; return x;} Imp2: int exp2(int x, int y) { x = x << y; return x;} Imp3: int exp2(int x, int y) { return HW_EXP(x,y);} Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 12

API: Application Program Interface Three most common APIs: Win32 API for Windows http://en.wikipedia.org/wiki/windows_api http://msdn.microsoft.com/enus/library/windows/desktop/ff818516%28v=vs.85%29.aspx POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X) POSIX Portable Operating System Interface for Unix http://en.wikipedia.org/wiki/posix http://www.unix.org/version4/gs5_apis.pdf Java API for the Java virtual machine (JVM) Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 13

An Example of System Calls System call sequence to copy the contents of one file to another file Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 14

An Example of Standard API Consider the ReadFile() function in the Win32 API a function for reading from a file A description of the parameters passed to ReadFile() HANDLE file the file to be read LPVOID buffer a buffer where the data will be read into and written from DWORD bytestoread the number of bytes to be read into the buffer LPDWORD bytesread the number of bytes read during the last read LPOVERLAPPED ovl indicates if overlapped I/O is being used Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 15

API System Call OS Relationship Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 16

Standard C Library Example C program invoking printf() library call, which calls write() system call Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 17

Why use API? Simplicity API is designed for applications Portability API is an unified defined interface Efficiency Not all functions require OS services or involve kernel Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 18

System Calls: Passing Parameters Three general methods are used to pass parameters between a running program and the operating system. Pass parameters in registers Store the parameters in a table in memory, and the table address is passed as a parameter in a register Push (store) the parameters onto the stack by the program, and pop off the stack by operating system Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 19

Parameter Passing via Table Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 20

Review Slides (1) What are the two communication models provided by OS? What is the relationship between system calls, API and C library? Why use API rather than system calls? Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 21

System Structure: Simple OS Architecture Layer OS Architecture Microkernel OS Modular OS Structure Virtual Machine Java Virtual Machine Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 22

User goals and System goals User goals operating system should be easy to use and learn, as well as reliable, safe, and fast System goals operating system should be easy to design, implement, and maintain, as well as reliable, error-free, and efficient Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 23

Simple OS Architecture Only one or two levels of code Drawbacks: Un-safe, difficult to enhance MS-DOS UNIX Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 24

Layered OS Architecture Lower levels independent of upper levels N th layer can only access services provided by 0~(N-1) th layer Pros: Easier debugging/maintenance Cons: Less efficient, difficult to define layers Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 25

Microkernel OS Moves as much from the kernel into user space Communication is provided by message passing Easier for extending and porting Processes Microkernel Graphics Subsystems Applications I/O Manager Applications Processes Network Drivers Device Drivers Graphics Drivers Hardware Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 26

Modular OS Architecture Most modern OS implement kernel modules Uses object-oriented approach Each core component is separate Each talks to the others over known interfaces Each is loadable as needed within the kernel Similar to layers but with more flexible E.g., Solaris How to write kernel module http://www.linuxchix.org/content/courses/kernel_hacking/lesson8 http://en.wikibooks.org/wiki/the_linux_kernel/modules https://www.thc.org/papers/lkm_hacking.html Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 27

Virtual Machine A virtual machine takes the layered approach to its logical conclusion It treats hardware and the operating system kernel as though they were all hardware A virtual machine provides an interface identical to the underlying bare hardware Each process is provided with a (virtual) copy of the underlying computer Difficult to achieve due to critical instruction Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 28

Virtual Machine Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 29

Usage of Virtual Machine provides complete protection of system resources a means to solve system compatibility problems a perfect vehicle for operating-systems research and development A mean to increase resources utilization in cloud computing Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 30

Vmware (Full Virtualization) Run in user mode as an application on top of OS Virtual machine believe they are running on bare hardware but in fact are running inside a user-level application Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 31

Para-virtualization: Xen Presents guest with system similar but not identical to the guest s preferred systems (Guest must be modified) Hardware rather than OS and its devices are virtualized (Only one kernel installed) Within a container (zone) processes thought they are the only processes on the system Solaris 10: creates a virtual layer between OS and the applications Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 32

Java Virtual Machine Compiled Java programs are platform-neutral bytecodes executed by a Java Virtual Machine (JVM) JVM consists of - class loader - class verifier - runtime interpreter Just-In-Time (JIT) compilers increase performance Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 33

Review Slides (2) What is the difference between the layer approach, the modular approach and microkernel? What are the advantages of using virtual machine? Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 34

Reading Material & HW Chap 2 HW (Problem set) 2.7, 2.10, 2.13 Reference Understanding Full Virtualization, Paravirtualization, and Hardware Assist www.vmware.com/files/pdf/vmware_paravirtualization.pdf APIs, POSIX and the C Library http://book.chinaunix.net/special/ebook/linux_kernel_develo pment/0672327201/ch05lev1sec1.html Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 35

Backup Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 36

OS/2 Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 37

Mac OS X Structure hybrid structured I/O kit for device drivers Dynamically loadable modules CLI, POSIX APIs file systems, networking, MM, RPCs, IPC, thread scheduling Message passing Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 38

Simulation Simulation: the host system has one system architecture and the guest system was complied for a different architecture The programs (such as important programs that were compiled for the old system) could be run in an emulator that translates each of the outdated system s instructions into the current instruction set. (disadv.: 10 times slow usually) Chapter2 OS-Structure Operating System Concepts NTHU LSA Lab 39