Site hosted by Angelfire.com: Build your free website today!

Department of Computer Science, UMass Amherst Andrew H. Fagg

Announcements

˛ Lab 0 due Friday

˛ HW 1 out tonight

CMPSCI 377: Operating Systems Lecture 3, Page 1

Department of Computer Science, UMass Amherst Andrew H. Fagg

Last Class: OS and Computer Architecture

CPU

System Bus

Disk

Controller

Printer Tape Drive

Controller Controller

Memory Controller

disk disk

printer

tape drive

Memory

CMPSCI 377: Operating Systems Lecture 3, Page 2

Department of Computer Science, UMass Amherst Andrew H. Fagg

Last Class: OS and Computer Architecture

OS Service Hardware Support

Protection Kernel/User mode

Protected Instructions

Base and Limit Registers

Interrupts Interrupt Vectors

System calls Trap instructions and trap vectors

I/O Interrupts or Memory-Mapping

Scheduling, error recovery, billing Timer

Synchronization Atomic instructions

Virtual memory Translation look-aside bu®ers

CMPSCI 377: Operating Systems Lecture 3, Page 3

Department of Computer Science, UMass Amherst Andrew H. Fagg

Today: OS Structures & Services

˛ Introduce the organization and components in an OS.

˛ OS Components

{ Processes

{ Synchronization

{ Memory & Secondary Storage Management

{ File Systems

{ I/O Systems

{ Distributed Systems

˛ Three example OS organizations

{ Monolithic kernel

{ Layered architecture

{ Microkernel

CMPSCI 377: Operating Systems Lecture 3, Page 4

Department of Computer Science, UMass Amherst Andrew H. Fagg

From the Architecture to the OS to the User

From the Architecture to the OS to the User: Architectural resources,

OS management, and User Abstractions.

Hardware

Abstraction

Example OS Services User Abstraction

Processor Process management,

Scheduling, Traps Protection,

Billing, Synchronization

Process

Memory Management, Protection,

Virtual memory

Address space

I/O devices Concurrency with CPU,

Interrupt handling

Terminal, Mouse, Printer,

System Calls

File system Management, Persistence Files

Distributed

systems

Network security, Distributed

Żle system

RPC system calls, Żle

sharing

CMPSCI 377: Operating Systems Lecture 3, Page 5

Department of Computer Science, UMass Amherst Andrew H. Fagg

Processes

˛ The OS manages a variety of activities:

{ User programs

{ Batch jobs and command scripts

{ System programs: printers, spoolers, name servers, Żle servers, network

listeners, etc.

˛ Each of these activities is encapsulated in a process.

˛ A process includes the execution context (PC, registers, VM, resources,

etc.) and all the other information the activity needs to run.

˛ A process is not a program. A process is one instance of a program in

execution. Many processes can be running the same program. Processes

are independent entities.

CMPSCI 377: Operating Systems Lecture 3, Page 6

Department of Computer Science, UMass Amherst Andrew H. Fagg

OS and Processes

˛ The OS creates, deletes, suspends, and resumes processes.

˛ The OS schedules and manages processes.

˛ The OS manages inter-process communication and synchronization.

˛ The OS allocates resources to processes.

˛ How are processes created in unix? ... in Windows?

˛ What is the function of \the shell"?

CMPSCI 377: Operating Systems Lecture 3, Page 7

Department of Computer Science, UMass Amherst Andrew H. Fagg

Interprocess Communication

Moving data between processes (possibly across processors)

˛ Message passing

{ Common across di®erent computers

{ Usually perform explicit connection opening and closing operations (so

must know how to address the remote process)

{ Requires one to explicitly package a set of bytes to be sent to the other

end (and the bytes are copies, even if the destination is on the same

machine).

CMPSCI 377: Operating Systems Lecture 3, Page 8

Department of Computer Science, UMass Amherst Andrew H. Fagg

Interprocess Communication (cont)

˛ Shared memory

{ Most common within a single processor or across processors located in

the same machine (the Torso control architecture is an exception to

this)

{ Very convenient programming model (simply write bytes to memory

locations)

{ But: need explicit synchronization mechanisms

CMPSCI 377: Operating Systems Lecture 3, Page 9

Department of Computer Science, UMass Amherst Andrew H. Fagg

Synchronization Example

Banking transactions:

˛ Cooperating processes on a single account: ATM machine transaction,

balance computation, Monthly interest computation and addition.

˛ All of the processes are trying to access the same account simultaneously.

What can happen?

Many other situations where synchronization becomes important, e.g.:

˛ Distributed Żle systems

˛ Robot control

CMPSCI 377: Operating Systems Lecture 3, Page 10

Department of Computer Science, UMass Amherst Andrew H. Fagg

Memory & Secondary Storage Management

Main memory

˛ Is the direct access storage for the CPU.

˛ Processes must be stored in main memory to execute.

˛ The OS must:

{ Allocate memory space for processes.

{ Deallocate memory space.

{ Maintain the mappings from virtual to physical memory (page tables).

{ Decide how much memory to allocate to each process, and when a

process should be removed from memory (policies).

CMPSCI 377: Operating Systems Lecture 3, Page 11

Department of Computer Science, UMass Amherst Andrew H. Fagg

File System

Secondary storage devices (disks) are too crude to use directly for long term

storage.

˛ The Żle system provides logical objects and operations on these objects

(Żles).

˛ A Żle is the long-term storage entity: a named collection of persistent

information that can be read or written.

˛ File systems support directories which contain the names of Żles and

other directories along with additional information about the Żles and

directories (e.g., when they were created and last modiŻed).

CMPSCI 377: Operating Systems Lecture 3, Page 12

Department of Computer Science, UMass Amherst Andrew H. Fagg

File System Management

˛ The File System provides Żle management, a standard interface to :

{ Create and delete Żles and directories.

{ Manipulate (read, write, extend, rename, copy, protect) Żles and

directories.

{ Map Żles onto secondary storage.

˛ The File System also provides general services such as backups,

maintaining mapping information, accounting, and quotas.

˛ Various models of Żle access protection:

{ Unix and Network File System (NFS)

{ Andrew File System (AFS)

CMPSCI 377: Operating Systems Lecture 3, Page 13

Department of Computer Science, UMass Amherst Andrew H. Fagg

Secondary Storage (disk)

˛ Secondary Storage = persistent memory (endures system failures)

˛ Low-level OS routines: responsible for low-level disk functions, such as

scheduling of disk operations, head movement, and error handling.

{ These routines may also be responsible for managing the disk space

(for example, keeping track of the free space).

{ The line between managing the disk space and the Żle system is very

fuzzy, these routines are sometimes in the Żle system.

˛ Example: A program executable is stored in a Żle on disk. To execute a

program, the OS must load the program from disk into memory.

CMPSCI 377: Operating Systems Lecture 3, Page 14

Department of Computer Science, UMass Amherst Andrew H. Fagg

I/O Systems

The I/O system supports communication with external devices: terminal,

keyboard, printer, mouse, ...

The I/O system

˛ Supports bu®ering/spooling of I/O

˛ Provides a general device driver interface, hiding the di®erences among

devices

˛ Provides device driver implementations speciŻc to individual devices.

˛ Common to treat I/O devices as Żles (both unix and MS-DOS do this).

CMPSCI 377: Operating Systems Lecture 3, Page 15

Department of Computer Science, UMass Amherst Andrew H. Fagg

Distributed Systems

˛ A distributed system is a collection of processors that do not share

memory or a clock.

{ To use non-local resources in a distributed system, processes must

communicate over a network,

{ The OS must provide additional mechanisms for dealing with failures

and deadlock that are not encountered in a centralized system.

˛ The OS can support a distributed Żle system on a distributed system.

{ Users, servers, and storage devices are all dispersed among the various

sites.

{ The OS must carry out its Żle services across the network and manage

multiple, independent storage devices.

CMPSCI 377: Operating Systems Lecture 3, Page 16

Department of Computer Science, UMass Amherst Andrew H. Fagg

One Basic OS Structure

Signals

Terminals

Character I/O

Files,

Swapping,

Tapes, etc.

CPU Scheculing

Page Replacement

Virtual Memory

System Services: shell, compilers

libraries, etc.

Terminal

User Programs

System Calls

Kernel

Hardware

Device

Controllers Controllers

Physical Machine

handling routines

Independent

Machine

Machine

Dependent

CMPSCI 377: Operating Systems Lecture 3, Page 17

Department of Computer Science, UMass Amherst Andrew H. Fagg

One Basic OS Structure (cont)

˛ The kernel is the protected part of the OS that runs in kernel mode,

protecting the critical OS data structures and device registers from user

programs.

˛ Debate about what functionality goes into the kernel

CMPSCI 377: Operating Systems Lecture 3, Page 18

Department of Computer Science, UMass Amherst Andrew H. Fagg

Layered OS design

existing operations

layer M

layer M-1 hidden

operations

new operations

CMPSCI 377: Operating Systems Lecture 3, Page 19

Department of Computer Science, UMass Amherst Andrew H. Fagg

Layered OS design (cont)

˛ Advantages: modularity, simplicity, portability, ease of design/debugging

˛ Disadvantage - communication overhead between layers, extra copying,

book-keeping

CMPSCI 377: Operating Systems Lecture 3, Page 20

Department of Computer Science, UMass Amherst Andrew H. Fagg

Microkernel

File System

High-Level

Scheduling

System

Thread Support

Network

Communication

Protection

Processor

Control Low-Level VM

Hardware

User Mode

Kernel Mode

Microkernel

System

Processes

User Processes

External

Paging

CMPSCI 377: Operating Systems Lecture 3, Page 21

Department of Computer Science, UMass Amherst Andrew H. Fagg

Microkernel Features

˛ Goal: to minimize what goes in the kernel (mechanism, no policy),

implementing as much of the OS in User-Level processes as possible.

˛ Advantages: better reliability, easier extension and customization

˛ Disadvantages: mediocre performance (unfortunately)

˛ First Microkernel was Hydra (CMU '70). Current systems include Chorus

(France), Mach (CMU), and QNX (commercial, real-time OS).

CMPSCI 377: Operating Systems Lecture 3, Page 22

Department of Computer Science, UMass Amherst Andrew H. Fagg

Summary

Big Design Issue: How do we make the OS e±cient, reliable, and

extensible?

General OS Philosophy: The design and implementation of an OS involves

a constant trade-o® between simplicity and performance. As a general

rule, strive for simplicity except when you have a strong reason to believe

that you need to make a particular component complicated to achieve

acceptable performance (strong reason = simulation or evaluation study).

CMPSCI 377: Operating Systems Lecture 3, Page 23

Department of Computer Science, UMass Amherst Andrew H. Fagg

Next Time

˛ Friday: Java fundamentals (including graphics) and Lab 1

˛ Monday: Read chapter 4 (Process Management)

CMPSCI 377: Operating Systems Lecture 3, Page 24