• Non ci sono risultati.

Chapter 15 – Part 1

N/A
N/A
Protected

Academic year: 2021

Condividi "Chapter 15 – Part 1"

Copied!
32
0
0

Testo completo

(1)

Chapter 15 – Part 1

The Internal Operating System

The Architecture of Computer Hardware and Systems Software:

An Information Technology Approach 3rd Edition, Irv Englander

John Wiley and Sons 2003

Wilson Wong, Bentley College Linda Senne, Bentley College

(2)

Chapter 15

The Internal Operating System – Part 1 15.1-2

OS Internals – Part I

 Process Scheduling

 CPU Scheduling

 Memory Management

 Virtual Storage

(3)

Target Model

(4)

Chapter 15

The Internal Operating System – Part 1 15.1-4

Network Services File management

Device management / Resource allocation

Memory management / Scheduling

Monitor IOCS (I/O control system)

Translates logical file requests

Load programs into MM Allocates execution time Provides overall system control

Loading and Executing a Program

(5)

Multi-Tasking System

 The OS must allocate resources (CPU, memory, I/O) to multiple processes

 Different scheduling routines are used for different objectives

(6)

Chapter 15

The Internal Operating System – Part 1 15.1-6

Processes

Process: basic unit of work in the OS

A program together with all the resources that are associated with it as it is executed

Program: a file or listing

Process: a program being executed

Independent vs. cooperating processes

PID (process ID): a unique identifier for each process

Process creation: user vs. system

Forking, spawning, cloning a new process

Parent and child processes

(7)

Process Control Block

A block of data for each process in the system

Contains all relevant information about the process

Typical process

control block on the right 

(8)

Chapter 15

The Internal Operating System – Part 1 15.1-8

Two Processes Sharing a

Single Program

(9)

Process States

Three primary process operating states

Ready state

Running state

Blocked state

Dispatching - Move from ready state to running state

Wake-up - Move from blocked state to ready state

Time-out - Move from running state to ready state

Process completion

killed, terminated, destroyed

Additional states – suspend, swap

Resumption – Move from suspended state to ready state

(10)

Chapter 15

The Internal Operating System – Part 1 15.1-10

Process State Diagram

(11)

Threads

‘Miniprocess’ that can be run independent of other parts of the process

Event-driven programs

No control blocks

Shares resources allocated to its parent process including primary storage, files and I/O devices

Advantage of process/thread families over multiple independent processes:

Reduced OS overhead for resource allocation and process management

Substantially less information than a normal PCB

(12)

Chapter 15

The Internal Operating System – Part 1 15.1-12

CPU Scheduling

High-level scheduling Adding a program to the pool of programs to be executed

Short-term scheduling (dispatcher)

Deciding which process shall be executed next by the processor Mid-level scheduling Swapping processes

I/O scheduling Deciding which process’s pending I/O request shall be handled by an

available I/O device

(13)

Dispatching Objectives

 Maximize throughput

 Minimize turnaround time

 Maximize CPU utilization

 Maximize resource allocation

 Promote graceful degradation

 Provide minimal and consistent response time

Prevent starvation

(14)

Chapter 15

The Internal Operating System – Part 1 15.1-14

Nonpreemptive Dispatching

 First in, first out (FIFO)

Unfair to short processes and I/O based processes

 Shortest Job First (SJF)

Longer jobs can be starved

 Priority Scheduling

Dispatcher selects among jobs with the same priorities

(15)

Preemptive Dispatching

Round robin

Inherently fair and maximizes throughput

Dynamic Priority

Based on ratio of CPU time to total time process has been in the system

Smallest ratio has highest priority

Linux, Windows 2000

(16)

Chapter 15

The Internal Operating System – Part 1 15.1-16

Preemptive Dispatching

Multilevel feedback queues

Favors short jobs, I/O bound jobs

Each level assigns more CPU time

(17)

Memory Management

Memory Partitioning

Fixed

Variable

Best fit, first-fit, largest-fit algorithms

Memory fragmentation

Overlays

Programs are divided into small logical pieces for execution

Pieces are loaded into memory as needed

Memory Relocation

Addresses have to be adjusted unless relative addressing is used

(18)

Chapter 15

The Internal Operating System – Part 1 15.1-18

Memory Overlays

(19)

Virtual Memory

Virtual memory increases the apparent amount of memory by using far less

expensive hard disk space

Provides for process separation

Demand paging

Pages brought into memory as needed

Page table

Keeps track of what is in memory and what is still out on hard disk

(20)

Chapter 15

The Internal Operating System – Part 1 15.1-20

Frames and Pages

Program Memory

Unit Page Frame

Address Logical Physical

Size 2 to 4KB 2 to 4KB

Amount # of bits in

instruction word Installed memory

(21)

Frames and Pages

Binary Paging

(22)

Chapter 15

The Internal Operating System – Part 1 15.1-22

Dynamic Address Translation

(23)

Disk

Page Frame

Pages not in main memory:

page fault when accessed

1 2 3 4

5 6 7 8

9 10 11 1

2 3 4 5 6 7 8 9 10 11

6 4 8 10 1 2 7

Page Table

Swap space

(24)

Chapter 15

The Internal Operating System – Part 1 15.1-24

Steps in Handling a Page Fault

(25)

Locality of Reference

Most memory references confined to small region

Well-written program in small loop, procedure or function

Data likely in array and variables stored together

Working set

Number of pages sufficient to run program normally, i.e., satisfy locality of a particular program

(26)

Chapter 15

The Internal Operating System – Part 1 15.1-26

Page Replacement Algorithms

Page fault - page is not in memory and must be loaded from disk

Algorithms to manage swapping

First-In, First-Out FIFO – Belady’s Anomaly

Least Recently Used LRU

Least Frequently Used LFU

Not Used Recently NUR

Referenced bit, Modified (dirty) bit

Second Chance Replacement algorithms

Thrashing

too many page faults affect system performance

(27)

Virtual Memory Tradeoffs

Disadvantages

SWAP file takes up space on disk

Paging takes up resources of the CPU Advantages

Programs share memory space

More programs run at the same time

Programs run even if they cannot fit into memory all at once

Process separation

(28)

Chapter 15

The Internal Operating System – Part 1 15.1-28

Virtual Memory vs. Caching

 Cache speeds up memory access

 Virtual memory increases amount of perceived storage

Independence from the configuration and capacity of the memory system

Low cost per bit compared to main memory

(29)

Secondary Storage Scheduling

First-Come, First-Served

Shortest Distance First

Indefinite postponement problem

Scan

Middle of disk gets serviced twice

N-Step C-Scan

Disk seek in only one direction

Return after last request in queue served

Two queues

Queue of requests being processed

Queue of new requests

(30)

Chapter 15

The Internal Operating System – Part 1 15.1-30

Other OS Issues

 Deadlock

Two processes have one another’s

resources that the other needs in order to proceed

Prevention

Avoidance

Detection and recovery

 Process Synchronization

(31)

Java Virtual Machine

(32)

Chapter 15

The Internal Operating System – Part 1 15.1-32

Copyright 2003 John Wiley & Sons

All rights reserved. Reproduction or translation of this work beyond that permitted in Section 117 of the 1976 United States Copyright Act without express permission of the copyright owner is unlawful. Request for further information should be addressed to the permissions Department, John Wiley & Songs, Inc. The purchaser may make back-up copies for his/her own use only and not for distribution or resale. The Publisher assumes no responsibility for errors, omissions, or damages caused by the use of these programs or from the use of the

information contained herein.”

Riferimenti

Documenti correlati

  Con n processi nella coda e un quanto di tempo = q, ogni processo riceve 1/n di CPU time in blocchi di q unità per

After one shift (for instance 12 hours) on duty, a doctor has to rest for at least a number r 1 of shifts (for instance 4 shifts, 48 hours, or sometimes even less, depending on

• Il problema consiste, ad esempio, nel determinare l'ordinamento delle operazioni in modo da terminare tutte le lavorazioni il prima possibile... Esempio 2:

Starvation: si verifica quando uno o più processi di priorità bassa vengono lasciati indefinitamente nella coda dei processi pronti, perchè vi è sempre almeno un processo pronto

In FP, the response time of a task depends only on its computation time and on the interference of higher priority tasks. In EDF, it depends in the parameters of

Generalization to deadlines different from period Synchronous and asynchronous

exposed to and appreciated the strengths of C, but also appreciated the power and convenience of higher-level languages like Simula, which had language support for

 Ogni task riceve la CPU per un tempo massimo pari al quantum e poi viene inserito nuovamente nella ready queue.  La ready queue è gestita con