CS307 Operating Systems Operating Systems

Introduction

Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2020

Operating Systems 2

Operating Systems Four Components of a Computer System

-family: BSD(Berkeley Software Distribution), System-V, GNU/, , Nachos, OS X, iOS People, machines, other  BSD-family: FreeBSD, NetBSD, OpenBSD computers  System-V-family: AIX, HP-UX, IRIX, Solaris  Linux-family: Red Hat, Debian, Ubuntu, Fedora, openSUSE, Linux Mint, Application programs Google's Android, WebOS, Meego define the ways in which theSystem system programs resources are  MS-DOS, Microsoft Windows, Windows Mobile, Win-CE, WP8 arecomputer used to software solve the  AmigaOS computingdesigned to problems operate theof thecomputer users hardware and  , MeeGo toControls provide and a platformcoordinates for  Google Chrome OS runninguse of hardware application among programsvarious applications and  OS/2 users  XrossMediaBar(XMB) for PS3, Orbis OS for PS4 provides basic computing  Input Output System for Wii resources  Tiny-OS, LynxOS, QNX, VxWorks

Operating Systems 3 Operating Systems 4

Computer System Structure What is an ?

 Hardware – provides basic computing resources  An operating system is a program that manages the computer hardware  CPU, memory, I/O devices  A program that acts as an intermediary between the computer user and the  Operating system – Controls and coordinates use of hardware among computer hardware various applications and users  System programs – are computer software designed to operate the computer hardware and to provide a platform for running application  Operating system goals: programs  Execute user programs and make solving user problems easier  BIOS and device drivers  Make the computer system convenient to use  Application programs – define the ways in which the system resources  Use the computer hardware in an efficient manner are used to solve the computing problems of the users  Word processors, compilers, web browsers, database systems, video games  Users  People, machines, other computers

Operating Systems 5 Operating Systems 6

1 Operating System Definition Operating System Definition (Cont.)

 No universally accepted definition  OS is a resource allocator  Manages all resources  “Everything a vendor ships when you order an operating system” is good  Decides between conflicting requests for efficient and fair resource use approximation  But varies wildly

 OS is a control program  “The one program running at all times on the computer” is the kernel.  Controls execution of programs to prevent errors and improper use of the computer Everything else is either a system program (ships with the operating system) or an application program.

 “An operating system (OS) is software, consisting of programs and data, that runs on computers, manages computer hardware resources, and provides common services for execution of various application software.” --- From Wikipedia

Operating Systems 7 Operating Systems 8

Operating System Structures Virtual Machines

(a) Bare Machine (b) Virtual Machine

Operating Systems 9 Operating Systems 10

Course Outline Process Scheduling

•Main Memory •Virtual Memory MEMORY MANAGEMENT •Processes •File-System Interface •Threads •File-System •CPU PROCESS STORAGE Implementation Scheduling MANAGEMENT MANAGEMENT •Mass-Storage •Process Structure Synchronization •I/O Systems •Deadlocks OPERATING SYSTEMS

DISTRIBUTED SYSTEMS

Operating Systems 11 Operating Systems 12

2 Single and Multithreaded Processes CPU Scheduling

 First-Come, First-Served (FCFS) Scheduling  Shortest-Job-First (SJF) Scheduling  Priority Scheduling  Round-Robin Scheduling  Multilevel Queue Scheduling  Multilevel Feedback Queue Scheduling

Operating Systems 13 Operating Systems 14

Process Synchronization Deadlock Avoidance

Example of Banker’s Algorithm Dining-Philosophers Problem  5 processes P0 through P4;  Philosophers spend their lives thinking and eating 3 resource types:  Don’t interact with their neighbors, occasionally try to pick up 2 chopsticks A (10 instances), B (5 instances), and C (7 instances) (one at a time) to eat from bowl Snapshot at time T :  Need both to eat, then release both when done 0 Max Allocation Need Available  In the case of 5 philosophers A B C A B C A B C A B C  Shared data P0 7 5 3 0 1 0 7 4 3 3 3 2  Bowl of rice (data set) P1 3 2 2 2 0 0 1 2 2  Semaphore chopstick [5] initialized to 1 P2 9 0 2 3 0 2 6 0 0

P3 2 2 2 2 1 1 0 1 1

P4 4 3 3 0 0 2 4 3 1

 The system is in a safe state since the sequence < P1, P3, P0, P2, P4> satisfies safety criteria

Operating Systems 15 Operating Systems 16

Memory Management Virtual Memory Management

Paging Hardware

Operating Systems 17 Operating Systems 18

3 Mass-Storage Systems File-System

cylinder 7 0 15 8 sector

6 1 14 9

13 5 10 2

11 block 12 4 3

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 …… Combined Scheme with UNIX I-node

Operating Systems 19 Operating Systems 20

I/O Systems Distributed System Structure

Operating Systems 21 Operating Systems 22

Homework

 Reading  Chapter 1: Introduction

Operating Systems 23

4