Operating System Structure

Similar documents
Operating System Structure

Computer Architecture and OS. EECS678 Lecture 2

Chapter 2. Operating-System Structures

Roadmap. CPU management. Memory management. Disk management. Other topics. Process, thread, synchronization, scheduling. Virtual memory, demand paging

Quiz: Address Translation

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

Chapter 2: Operating-System Structures

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

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

Operating System Architecture. CS3026 Operating Systems Lecture 03

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

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission 1

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

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.

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

EECS 678: Introduction to Operating Systems. Heechul Yun

CS370 Operating Systems

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

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

Module 1 Introduction/OS Overview

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

Chapter 2: System Structures

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

Chapter 2: Operating-System Structures

Introduction to Operating Systems (Part III)

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

Four Components of a Computer System

OS Structures. ICS332 Operating Systems

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

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

Chapter 2: System Structures

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

CSE 4/521 Introduction to Operating Systems

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

Chapter 2: Operating-System

Chapter 2: Operating-System Structures

Operating-System Structures

CS420: Operating Systems. OS Services & System Calls

Operating System Services

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

Operating-System Structures

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

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

Chapter 2: Operating-System Structures

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

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

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

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

COS 318: Operating Systems

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

Chapter 2: Operating-System Structures

Chap2: Operating-System Structures

COS 318: Operating Systems

Chapter 2 Operating-System Structures

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

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission

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

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

CSE 333 SECTION 3. POSIX I/O Functions

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

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission 1

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

CS 300 Leftovers. CS460 Pacific University 1

Lecture 2 Operating System Structures (chapter 2)

CISC2200 Threads Spring 2015

OS COMPONENTS OVERVIEW OF UNIX FILE I/O. CS124 Operating Systems Fall , Lecture 2

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

Chapter 2: OS Structures

Operating Systems Overview. Chapter 2

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

Process Description and Control

CSE Opera+ng System Principles

CS 390 Chapter 2 Homework Solutions

Lecture 1 OS Introduction. Bo 2018, Spring

CPS221 Lecture: Operating System Functions

Distributed Systems Operation System Support

Operating System Structure

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

CS420: Operating Systems

CPS221 Lecture: Operating System Functions

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

EECS 3221 Operating System Fundamentals

EECS 3221 Operating System Fundamentals

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

Operating systems. Lecture 7

CS307: Operating Systems

Operating System Concepts Ch. 2: Operating System Structures

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song Spring 2015

TCSS 422: OPERATING SYSTEMS

L4/Darwin: Evolving UNIX. Charles Gray Research Engineer, National ICT Australia

CSCI 6411: Operating Systems. Acknowledgements: Some slide material derived from Silberschatz, et al.

CSCE-313 Introduction to Computer Systems

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

CS140 Operating Systems Final December 12, 2007 OPEN BOOK, OPEN NOTES

Process Characteristics

Chapter 2 Operating System Structures

The Classical OS Model in Unix

Transcription:

Operating System Structure Heechul Yun Disclaimer: some slides are adopted from the book authors slides with permission

Recap OS needs to understand architecture Hardware (CPU, memory, disk) trends and their implications in OS designs Architecture needs to support OS Interrupts and timer User/kernel mode and privileged instructions MMU Synchronization instructions 2

Recap: Memory Hierarchy Fast, Expensive Slow, Inexpensive 3

Memory Protection How to protect memory among apps/kernel? Applications shouldn t be allowed to access kernel s memory An app shouldn t be able to access another app s memory 4

Virtual Memory How to overcome memory space limitation? Multiple apps must share limited memory space But they want to use memory as if each has dedicated and big memory space E.g.,) 1GB physical memory and 10 programs, each of which wants to have a linear 4GB address space 5

Virtual Memory Process A Process B Process C MMU Physical Memory 6

MMU Hardware unit that translates virtual address to physical address Defines the boundaries of kernel/apps Enable efficient use of physical memory Virtual address Physical address CPU MMU Memory 7

Synchronization Synchronization problem with threads Deposit(account, amount) { { account->balance += amount; } Thread 1: Deposiit(acc, 10) LOAD R1, account->balance ADD R1, amount STORE R1, account->balance Thread 2: : Deposiit(acc, 10) LOAD R1, account->balance ADD R1, amount STORE R1, account->balance 8

Synchronization Instructions Hardware support for synchronization TestAndSet, CompareAndSwap instructions Atomic load and store Used to implement lock primitives New TSX instruction hardware transaction Another methods to implement locks in single-core systems Disabling interrupts 9

Summary OS needs to understand architecture Hardware (CPU, memory, disk) trends and their implications in OS designs Architecture needs to support OS Interrupts and timer User/kernel mode and privileged instructions MMU Synchronization instructions 10

OS services Today User s perspective What are the major functionalities of an OS? OS interface How applications interact with the OS? OS structure What are possible structures of an OS? 11

A View of Operating System Services User Mode Kernel Mode Hardware 12

Operating System Services User interface Command-Line Interface (CLI) vs. Graphical User Interface (GUI) 13

Command-Line Interface (CLI) Command-line interpreter (shell) Many flavors: bash, csh, ksh, tcsh, Usually not part of the kernel, but an essential system program Allow users to enter text commands Some commands are built-in E.g., alias, echo, read, source, Some are external programs E.g., ls, find, grep, Pros and Cons. + Easy to implement, use less resources, easy to access remotely + Easy to automate E.g., $ grep bandwidth /tmp/test.txt awk '{ print $2 } Difficult to learn 14

Graphic User Interface (GUI) GUI Mouse, keyboard, monitor Invented at Xerox PARC, then adopted to Mac, Window, Pros and Cons + Easy to use - Use more h/w resources The first commercial GUI from Xerox Star workstation. (source: Wikipedia) Many systems support both CLI and GUI 15

Operating System Services File-system service Read/write /create/delete/search files and directories See file information (e.g., file size, creation time, access time, ) Permission management (read only, read/write, ) Communications Share information between processes in the same computer (Inter-process communication - IPC) or between computers over a network (TCP/IP) 16

Operating System Services Resource allocation CPU cycles, main memory space, file space, I/O devices Accounting Keeping track of who uses what for how much Security Login, administrators vs. normal users vs. guests 17

Operating System Services Protection Prevent memory corruption between multiple user programs and between user programs and the kernel Detect and report errors Divide by zero, access violation, hardware faults, 18

OS services CPU scheduling Memory management Filesystem Communication Protection & security Device drivers Recap 19

System Calls Programming interface to the services provided by the OS Typically written in a high-level language (C) Most programmers do not directly use system calls They use more high level APIs (i.e., libraries) But system programmers (or you) do use system calls Two most popular system call APIs Win32 API for Windows POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X) 20

Example Copy the contents of one file to another file int main(int argc, char *argv[]) { int src_fd, dst_fd; char buf[80]; int len; src_fd = open(argv[1], O_RDONLY); dst_fd = open(argv[2], O_WRONLY O_CREAT O_TRUNC); while ((len = read(src_fd, buf, 80)) > 0) { write(dst_fd, buf, len); } } printf( Done\n ); return 0; 21

Example Copy the contents of one file to another file int main(int argc, char *argv[]) { int src_fd, dst_fd; char buf[80]; int len; src_fd = open(argv[1], O_RDONLY); dst_fd = open(argv[2], O_WRONLY O_CREAT O_TRUNC); while ((len = read(src_fd, buf, 80)) > 0) { write(dst_fd, buf, len); } } printf( Done\n ); return 0; Syscalls: open, read, wrtie Non-syscall: printf 22

System Call API Description $ man 2 read 23

API - System Call - OS 24

Standard C Library Example C program invoking printf() library call, which calls write() system call 25

Types of System Calls Process control Create/terminate process, get/set process attributes, wait for time/event, allocate and free memory File management create, delete, open, close, read, write, reposition get and set file attributes Device management request device, release device, read, write, reposition, get device attributes, set device attributes Communications create, delete communication, send, receive messages Protection Control access to resources, get/set permissions, allow and deny user access 26

Examples of Windows and Unix System Calls 27

Operating System Structure Simple structure MS-DOS Monolithic kernel UNIX Microkernel Mach 28

MS-DOS Structure Written to provide the most functionality in the least space Minimal functionalities Not divided into modules Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated 29

UNIX: Monolithic Kernel Implements CPU scheduling, memory management, filesystems, and other OS modules all in a single big chunk User Application System call Process Management User Application Kernel Accounting User Application Protection boundary Memory Management Filesystem Disk I/O TCP/IP Device Drivers Pros and Cons + Overhead is low + Data sharing among the modules is easy Too big. (device drivers!!!) A bug in one part of the kernel can crash the entire system 30

Loadable Kernel Module Dynamically load/unload new kernel code Linux and most today s OSes support this User Application System call Process Management User Application Kernel Accounting User Application Protection boundary Memory Management Filesystem Disk I/O TCP/IP Device Drivers Pros and Cons + Don t need to have every driver in the kernel. + Easy to extend the kernel (just like micro kernel. See next) A bug in a module can crash the entire system 31

Microkernel Moves as much from the kernel into user space Communicate among kernels and user via message passing Application Program File System Device Driver user mode messages messages Interprocess Communication memory managment CPU scheduling kernel mode microkernel hardware Pros and Cons + Easy to extend (user level driver) + More reliable (less code is running in kernel mode) - Performance overhead of user space to kernel space communication 32

Hybrid Structure Most modern operating systems are actually not one pure model Hybrid combines multiple approaches to address performance, security, usability needs Linux and Solaris kernels in kernel address space, so monolithic, plus modular for dynamic loading of functionality Windows mostly monolithic, plus microkernel for different subsystem personalities Apple Mac OS X hybrid, layered Below is kernel consisting of Mach microkernel and BSD Unix parts, plus I/O kit and dynamically loadable modules (called kernel extensions) 33

OS Structure Comparison Source: http://en.wikipedia.org/wiki/monolithic_kernel 34