Slide 1-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter...

41
Operating Systems: A Modern Perspective, Chapter 1 Slide 1- 1 Copyright © 2004 Pearson Education, Inc.

Transcript of Slide 1-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter...

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-1

Copyright © 2004 Pearson Education, Inc.

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-2

Copyright © 2004 Pearson Education, Inc.

1Introduction

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-3

Copyright © 2004 Pearson Education, Inc.

Why Study Operating Systems?

• Understand the model of operation– Easier to see how to use the system– Enables you to write efficient code

• Learn to design an OS

• Even so, OS is pure overhead of real work

• Application programs have the real value to person who buys the computer

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-4

Copyright © 2004 Pearson Education, Inc.

What is an Operating System?

• A program or collection of programs that act as intermediary between the user of a computer and the computer hardware.

• Operating system goals:– Make the computer convenient to use.

– Use computer resources in an efficient manner.

– Coordinate among the various users and programs that are competing for computing resources.

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-5

Copyright © 2004 Pearson Education, Inc.

Perspectives of the Computer

ApplicationSoftware

SystemSoftware

Hardware

(a) End UserView

(b) ApplicationProgrammer

View

(c) OS ProgrammerView

ApplicationSoftware

ApplicationSoftware

SystemSoftware

SystemSoftware

Hardware Hardware

cutsave

printsend

malloc()fork()

open()read-disk

track-mouse

start-printer

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-6

Copyright © 2004 Pearson Education, Inc.

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-7

Copyright © 2004 Pearson Education, Inc.

Operating System Definition

• OS provides an interface between the computer hardware and users, applications and system software.

• OS manages computer resources.• OS controls and coordinates the use of the

computing resources among the various users/programs:– resource sharing among computer users/programs– protect users from each others

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-8

Copyright © 2004 Pearson Education, Inc.

System Software

•Independent of individual applications, but common to all of them

•Examples

–C library functions

–A window system

–A database management system

–Resource management functions

–The OS

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-9

Copyright © 2004 Pearson Education, Inc.

Using the System Software

LoaderLoader

OSOSDatabaseManagement

System

DatabaseManagement

System

WindowSystem

WindowSystem

ApplicationProgrammer

Sys

tem

Sof

twar

e

LibrariesLibraries

CompilerCompiler

Hardware

CommandLine

Interpreter

CommandLine

Interpreter

LibrariesLibrariesLibrariesLibraries

Software APISoftware API

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-10

Copyright © 2004 Pearson Education, Inc.

Application Software, System Software, and the OS

Hardware Resources

Trusted OS

(Abstract Resources)

Software-Hardware Interface

OS Interface

System Software

(More Abstract Resources)

API

Application Software

Human-Computer Interface

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-11

Copyright © 2004 Pearson Education, Inc.

The OS as Resource Manager

•Process: An executing program

•Resource: Anything that is needed for a process to run

–Memory

–Space on a disk

–The CPU

•“An OS creates resource abstractions”

•“An OS manages resource sharing”

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-12

Copyright © 2004 Pearson Education, Inc.

Resource Abstraction

load(block, length, device);seek(device, 236);out(device, 9)

write(char *block, int len, int device,int track, int sector) {

... load(block, length, device); seek(device, 236); out(device, 9); ...}

write(char *block, int len, int device,int addr);

fprintf(fileID, “%d”, datum);

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-13

Copyright © 2004 Pearson Education, Inc.

Disk Abstractions

load(…);seek(…);out(…);

void write() { load(…); seek(…) out(…)}

int fprintf(…) { ... write(…) …}

(a) Direct Control (b) write() abstraction

(c) fprintf() abstraction

ApplicationProgrammer

OS Programmer

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-14

Copyright © 2004 Pearson Education, Inc.

Abstract Resources

Hardware Resources

OS

OS Resources (OS Interface)

Middleware

Abstract Resources (API)

Application

User Interface

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-15

Copyright © 2004 Pearson Education, Inc.

Abstract Machines

ProgramProgram ResultResult

ProgramProgram ResultResult

ProgramProgram ResultResult

… …

Idea

Idea

Idea

PhysicalMachine

AbstractMachines

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-16

Copyright © 2004 Pearson Education, Inc.

Resource Sharing

• Space- vs time-multiplexed sharing

• To control sharing, must be able to isolate resources

• OS usually provides mechanism to isolate, then selectively allows sharing– How to isolate resources– How to be sure that sharing is acceptable

• Concurrency

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-17

Copyright © 2004 Pearson Education, Inc.

The OS as a Conductor

The OS coordinates the sharing and use of all the components in the computer

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-18

Copyright © 2004 Pearson Education, Inc.

Multiprogramming

AbstractMachine Pi

OS Resource Sharing

Pi MemoryPi Memory

Pk MemoryPk Memory

Pj MemoryPj Memory

…Time-multiplexed Physical Processor

AbstractMachine Pj

AbstractMachine Pk

Space-multiplexed Physical Memory

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-19

Copyright © 2004 Pearson Education, Inc.

Multiprogramming(2)• Technique for sharing the CPU among

runnable processes– Process may be blocked on I/O– Process may be blocked waiting for other

resource, including the CPU

• While one process is blocked, another might be able to run

• Multiprogramming OS accomplishes CPU sharing “automatically” – scheduling

• Reduces time to run all processes

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-20

Copyright © 2004 Pearson Education, Inc.

How Multiprogramming Works

Process 1

Process 2

Process 3

Process 4

Space-multiplexed Memory

Time-multiplexed CPU

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-21

Copyright © 2004 Pearson Education, Inc.

Speeding Up the Car Wash

VacuumInside

Wash Dry

VacuumInside

Wash Dry

(a) The Sequential Car Wash

(b) The Parallel Car Wash

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-22

Copyright © 2004 Pearson Education, Inc.

Multiprogramming Performance

Time

Using the processor

I/O operation

0 ti

Pi’s Total Execution Time, ti

(a) Pi’s Use of Machine Resources

Time

P1

P2

Pi

PN

(a) All Processes’ Use of Machine Resources

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-23

Copyright © 2004 Pearson Education, Inc.

OS Strategies

• Batch processing

• Timesharing

• Personal computer & workstations

• Process control & real-time

• Network

• Distributed

• Small computers

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-24

Copyright © 2004 Pearson Education, Inc.

Batch Processing

Job 19

Input Spooler Output Spooler

Job 3

Input Spool Output Spool

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-25

Copyright © 2004 Pearson Education, Inc.

Batch Processing(2)

• Uses multiprogramming

• Job (file of OS commands) prepared offline

• Batch of jobs given to OS at one time

• OS processes jobs one-after-the-other

• No human-computer interaction

• OS optimizes resource utilization

• Batch processing (as an option) still used today

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-26

Copyright © 2004 Pearson Education, Inc.

A Shell Script Batch File

cc -g -c menu.ccc -g -o driver driver.c menu.odriver < test_data > test_outlpr -PthePrinter test_outtar cvf driver_test.tar menu.c driver.c test_data test_outuuencode driver_test.tar driver_test.tar >driver_test.encode

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-27

Copyright © 2004 Pearson Education, Inc.

Timesharing Systems

PhysicalMachine

AbstractMachines

Command

Command

Command

Result

Result

Result

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-28

Copyright © 2004 Pearson Education, Inc.

Timesharing Systems(2)

• Uses multiprogramming

• Support interactive computing model (Illusion of multiple consoles)

• Different scheduling & memory allocation strategies than batch

• Tends to propagate processes

• Considerable attention to resource isolation (security & protection)

• Tend to optimize response time

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-29

Copyright © 2004 Pearson Education, Inc.

Personal Computers

• CPU sharing among one person’s processes

• Power of computing for personal tasks– Graphics– Multimedia

• Trend toward very small OS

• OS focus on resource abstraction

• Rapidly evolved to “personal multitasking” systems

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-30

Copyright © 2004 Pearson Education, Inc.

Process Control & Real-Time

• Computer is dedicated to a single purpose

• Classic embedded system

• Must respond to external stimuli in fixed time

• Continuous media popularizing real-time techniques

• An area of growing interest

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-31

Copyright © 2004 Pearson Education, Inc.

Networks

• LAN (Local Area Network) evolution• 3Mbps (1975) 10 Mbps (1980) 100 Mbps

(1990) 1 Gbps (2000)• High speed communication means new way to do

computing– Shared files– Shared memory– Shared procedures/objects– ???

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-32

Copyright © 2004 Pearson Education, Inc.

Distributed OS

• Wave of the future

Distributed OS

App App

App

App

AppApp

Multiple Computers connected by a Network

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-33

Copyright © 2004 Pearson Education, Inc.

Distributed Systems• Distribute the computation among several physical

processors.• Multiprocessor system: Tightly coupled systems –

processors share memory and a clock; communication usually takes place through the shared memory.

• Loosely coupled systems – each processor has its own local memory; processors communicate with one another through various communication lines

• Advantages of distributed systems:– Resource sharing, Computation speed up– Reliability, Communication

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-35

Copyright © 2004 Pearson Education, Inc.

Small Computers

• PDAs, STBs, embedded systems became commercially significant

• Have an OS, but– Not general purpose

– Limited hardware resources

– Different kinds of devices• Touch screen, no keyboard

• Graffiti

– Evolving & leading to new class of Oses

• PalmOS, Pocket PC (WinCE), VxWorks, …

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-36

Copyright © 2004 Pearson Education, Inc.

Evolution of Modern OS

Modern OS

Batch

Timesharing

PC & Wkstation

Network OS

Real-TimeMemory Mgmt

ProtectionScheduling

FilesDevices

Memory Mgmt

ProtectionScheduling

System software

Human-Computer Interface

Client-Server Model

Protocols

Scheduling

Small Computer

Network storage,Resource management

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-37

Copyright © 2004 Pearson Education, Inc.

Examples of Modern OS• UNIX variants (e.g. Linux) -- have evolved

since 1970• Windows NT/2K -- has evolved since 1989

(much more modern than UNIX– Win2K = WinNT, V5

• Research OSes – still evolving …• Small computer OSes – still evolving …• Book provides Linux examples• This course will use Windows NT as the

main example

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-38

Copyright © 2004 Pearson Education, Inc.

The Microsoft OS FamilyWin32 APIWin32 API

Windows CE(Pocket PC)

Windows CE(Pocket PC)

Windows 95/98/MeWindows 95/98/Me

Windows NT/2000/XPWindows NT/2000/XP

Win32 API SubsetWin32 API Subset

Win32 API SubSetWin32 API SubSet

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-39

Copyright © 2004 Pearson Education, Inc.

Microsoft Windows NT

• Heavily window-oriented• Foundation behavior is windows-

independent– We will focus on the foundation– Use only the “MS-DOS prompt” -- cmd.exe

OS API

NT Kernel

NT User Interfaceand Graphics

NT Executive

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-40

Copyright © 2004 Pearson Education, Inc.

Windows NT (cont)

• OS API has text orientation (like UNIX)

• Object-oriented implementation

• Heavy use of threads

• Broad spectrum of synchronization tools

• Modern I/O system

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-41

Copyright © 2004 Pearson Education, Inc.

ApplicationsApplications

VxWorks Runtime SystemVxWorks Runtime System

VxWorks Organization

VxWorks Configurable Core OS Extension

VxWorks Configurable Core OS Extension

Wind MicrokernelWind Microkernel

Operating Systems: A Modern Perspective, Chapter 1

Slide 1-42

Copyright © 2004 Pearson Education, Inc.

Windows CE Organization

Kernel

OEM Abstraction Layer

Win32 API (& Network Extensions)

Graphics,Window Mgr,

andEvent Mgr

Device Drivers

ObjectStore

Networkand

CommServices

Shells and Applications