introduction, concepts, review & historical perspective processes ◦ synchronization ◦...

36
Introduction to Operating Systems

Upload: kerry-butler

Post on 12-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

Introduction to Operating Systems

Page 2: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

2

Introduction, concepts, review & historical perspective

Processes◦ Synchronization◦ Scheduling◦ Deadlock

Memory management, address translation, and virtual memory

Operating system management of I/O File systems Distributed systems (as time permits)

CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)Chapter 1

Class outline

Page 3: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

3

A program that runs on the “raw” hardware and supports◦ Resource Abstraction◦ Resource Sharing

Abstracts and standardizes the interface to the user across different types of hardware◦ Virtual machine hides the messy details which must be

performed Manages the hardware resources

◦ Each program gets time with the resource◦ Each program gets space on the resource

May have potentially conflicting goals:◦ Use hardware efficiently◦ Give maximum performance to each user

CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)Chapter 1

What is an operating system?

Page 4: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

4

Storage pyramid

Goal: really large memory with very low latency◦ Latencies are smaller at the top of the hierarchy◦ Capacities are larger at the bottom of the hierarchy

Solution: move data between levels to create illusion of large memory with low latency

Chapter 1

CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)

Access latency

1 ns

2–5 ns

50 ns

5 ms

50 sec

< 1 KB

1 MB

256 MB

40 GB

> 1 TB

Capacity

Registers

Cache (SRAM)

Main memory (DRAM)

Magnetic disk

Magnetic tapeBetter

Better

Page 5: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

5

Processes Process: program in

execution◦ Address space (memory) the

program can use◦ State (registers, including

program counter & stack pointer)

OS keeps track of all processes in a process table

Processes can create other processes◦ Process tree tracks these

relationships◦ A is the root of the tree◦ A created three child

processes: B, C, and D◦ C created two child

processes: E and F◦ D created one child process:

GChapter 1

CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)

A

B

E F

C D

G

Page 6: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

6

CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)Chapter 1

Deadlock

Potential deadlock Actual deadlock

Page 7: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

Scheduling the processor among all ready processes

The goal is to achieve: ◦ High processor utilization◦ High throughput

number of processes completed per of unit time◦ Low response time

time elapsed from the submission of a request until the first response is produced

CPU Scheduling

Page 8: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

Long-term: which process to admit? Medium-term: which process to swap in or out? Short-term: which ready process to execute next?

Classification of Scheduling Activity

Page 9: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

Queuing Diagram for Scheduling

Page 10: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

The selection function determines which ready process is selected next for execution

The decision mode specifies the instants in time the selection function is exercised◦ Nonpreemptive

Once a process is in the running state, it will continue until it terminates or blocks for an I/O

◦ Preemptive Currently running process may be interrupted and

moved to the Ready state by the OS Prevents one process from monopolizing the

processor

Characterization of Scheduling Policies

Page 11: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

First-Come, First-Served Scheduling Shortest-Job-First Scheduling

◦ Also referred to as Shortest Process Next Round-Robin Scheduling

Scheduling Algorithms

Page 12: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

Process Mix Example

ProcessArriv

alTime

ServiceTime

1

2

3

4

5

0

2

4

6

8

3

6

4

5

2

Service time = total processor time needed in one (CPU-I/O) cycleJobs with long service time are CPU-bound jobs and are referredto as “long jobs”

Page 13: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

Selection function: the process that has been waiting the longest in the ready queue (hence, FCFS)

Decision mode: non-preemptive◦ a process runs until it blocks for an I/O

First Come First Served (FCFS)

Page 14: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

Selection function: the process with the shortest expected CPU burst time◦ I/O-bound processes will be selected first

Decision mode: non-preemptive The required processing time, i.e., the CPU

burst time, must be estimated for each process

Shortest Job First (Shortest Process Next)

Page 15: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

Selection function: same as FCFS Decision mode: preemptive

a process is allowed to run until the time slice period (quantum, typically from 10 to 100 ms) has expired

a clock interrupt occurs and the running process is put on the ready queue

Round-Robin

Page 16: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

Memory Management

Page 17: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

17

Subdividing memory to accommodate multiple processes

Memory needs to be allocated to ensure a reasonable supply of ready processes to consume available processor time

Memory Management

Page 18: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

18

Page 19: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

19

Equal-size partitions◦ Any process whose size is less than or equal to

the partition size can be loaded into an available partition

◦ If all partitions are full, the operating system can swap a process out of a partition

◦ A program may not fit in a partition. The programmer must design the program with overlays

Fixed Partitioning

Page 20: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

20

Main memory use is inefficient. Any program, no matter how small, occupies an entire partition. This is called internal fragmentation.

Fixed Partitioning

Page 21: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

21

Page 22: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

22

Page 23: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

23

Base register◦ Starting address for the process

Bounds register◦ Ending location of the process

These values are set when the process is loaded or when the process is swapped in

Registers Used during Execution

Page 24: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

24

Partition memory into small equal fixed-size chunks and divide each process into the same size chunks

The chunks of a process are called pages and chunks of memory are called frames

Operating system maintains a page table for each process◦Contains the frame location for each page in

the process◦Memory address consist of a page number

and offset within the page

Paging

Page 25: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

25

Assignment of Process Pages to Free Frames

Page 26: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

26

Assignment of Process Pages to Free Frames

Page 27: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

27

Page Tables for Example

Page 28: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

28

All segments of all programs do not have to be of the same length

There is a maximum segment length Addressing consist of two parts - a segment

number and an offset Since segments are not equal,

segmentation is similar to dynamic partitioning

Segmentation

Page 29: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

29

Page 30: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

30

Logical◦ Reference to a memory location independent of

the current assignment of data to memory◦ Translation must be made to the physical

address Relative

◦ Address expressed as a location relative to some known point

Physical◦ The absolute address or actual location in main

memory

Addresses

Page 31: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

31

Page 32: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

32

Page 33: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

Symmetric multiprocessing (SMP)◦ Each processor runs an identical copy of the

operating system.◦ Many processes can run at once without

performance deterioration.◦ Most modern operating systems support SMP

Asymmetric multiprocessing◦ Each processor is assigned a specific task;

master processor schedules and allocates work to slave processors.

◦ More common in extremely large systems

Parallel Systems

Page 34: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

Distribute the computation among several physical processors.

Loosely coupled system – each processor has its own local memory; processors communicate with one another through various communications lines, such as high-speed buses or telephone lines.

Advantages of distributed systems.◦ Resources Sharing ◦ Computation speed up – load sharing ◦ Reliability◦ Communications

Distributed Systems

Page 35: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

35

Definition:Tightly-coupled CPUs that do not share memory

Also known as ◦cluster computers◦clusters of workstations (COWs)

CS 1550, cs.pitt.edu (originaly modified from MOS2 slides by A.

Tanenbaum)

Multicomputers

Page 36: Introduction, concepts, review & historical perspective  Processes ◦ Synchronization ◦ Scheduling ◦ Deadlock  Memory management, address translation,

36

Interconnection topologies(a) single switch(b) ring(c) grid

(d) double torus(e) cube(f) hypercubeCS 1550, cs.pitt.edu (originaly

modified from MOS2 slides by A. Tanenbaum)

Multicomputer Hardware