34
Chapter 11: Chapter 11: Operating System Operating System Support Support Dr Mohamed Menacer Dr Mohamed Menacer Taibah University Taibah University 2007-2008 2007-2008

Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Embed Size (px)

Citation preview

Page 1: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Chapter 11:Chapter 11:Operating System Operating System

SupportSupport

Dr Mohamed MenacerDr Mohamed MenacerTaibah UniversityTaibah University

2007-20082007-2008

Page 2: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

O/S Objectives and FunctionsO/S Objectives and Functions

ConvenienceConvenience Making the computer easier to useMaking the computer easier to use

EfficiencyEfficiency Allowing better use of computer resourcesAllowing better use of computer resources

Page 3: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Layers and Views of a Computer SystemLayers and Views of a Computer System

Page 4: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Layers and Views of a Computer SystemLayers and Views of a Computer System

I/O systemProcessor

Compiler

Operating

System(Windows XP)

Application (MS Word)

Digital Design

Circuit Design

Instruction Set Architecture

Datapath & Control

transistors

MemoryHardware

Software Assembler

CS-233

Page 5: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Layers and Views of a Computer SystemLayers and Views of a Computer System

temp = v[k];v[k] = v[k+1];v[k+1] = temp;

High Level Language Program (e.g., C)

Assembly Language Program (e.g.,MIPS)

Machine Language Program (MIPS)

Control Signal Specification

Compiler

Assembler

Machine Interpretation

lw$to, 0($2)lw$t1, 4($2)sw$t1, 0($2)sw$t0, 4($2)

0000 1001 1100 0110 1010 1111 0101 10001010 1111 0101 1000 0000 1001 1100 0110 1100 0110 1010 1111 0101 1000 0000 1001 0101 1000 0000 1001 1100 0110 1010 1111

°°

Page 6: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Layers and Views of a Computer SystemLayers and Views of a Computer System

Page 7: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Operating System ServicesOperating System Services

Program creationProgram creation

Program executionProgram execution

Access to I/O devicesAccess to I/O devices

Controlled access to filesControlled access to files

System accessSystem access

Error detection and responseError detection and response

AccountingAccounting

Page 8: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

O/S as a Resource ManagerO/S as a Resource Manager

Page 9: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Types of Operating SystemTypes of Operating System

InteractiveInteractive

BatchBatch

Single program (Uni-programming)Single program (Uni-programming)

Multi-programming (Multi-tasking)Multi-programming (Multi-tasking)

Page 10: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Early SystemsEarly Systems

Late 1940s to mid 1950sLate 1940s to mid 1950s

No Operating SystemNo Operating System

Programs interact directly with hardwarePrograms interact directly with hardware

Two main problems:Two main problems: SchedulingScheduling Setup timeSetup time

Page 11: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Simple Batch SystemsSimple Batch Systems

Resident Monitor programResident Monitor program

Users submit jobs to operatorUsers submit jobs to operator

Operator batches jobsOperator batches jobs

Monitor controls sequence of events to Monitor controls sequence of events to process batchprocess batch

When one job is finished, control returns When one job is finished, control returns to Monitor which reads next jobto Monitor which reads next job

Monitor handles schedulingMonitor handles scheduling

Page 12: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Memory Layout for Resident MonitorMemory Layout for Resident Monitor

Page 13: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Desirable Hardware FeaturesDesirable Hardware Features

Memory protectionMemory protection To protect the MonitorTo protect the Monitor

TimerTimer To prevent a job monopolizing the systemTo prevent a job monopolizing the system

Privileged instructionsPrivileged instructions Only executed by MonitorOnly executed by Monitor e.g. I/Oe.g. I/O

InterruptsInterrupts Allows for relinquishing and regaining controlAllows for relinquishing and regaining control

Page 14: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Multi-programmed Batch Multi-programmed Batch SystemsSystems

I/O devices very slowI/O devices very slow

When one program is waiting for I/O, When one program is waiting for I/O, another can use the CPUanother can use the CPU

Page 15: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Single ProgramSingle Program

Page 16: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Multi-Programming with Multi-Programming with Two ProgramsTwo Programs

Page 17: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Multi-Programming with Multi-Programming with Three ProgramsThree Programs

Page 18: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

UtilizationUtilization

Page 19: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Time Sharing SystemsTime Sharing Systems

Allow users to interact directly with the Allow users to interact directly with the computercomputer i.e. Interactivei.e. Interactive

Multi-programming allows a number of Multi-programming allows a number of users to interact with the computerusers to interact with the computer

Page 20: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

SchedulingScheduling

Key to multi-programmingKey to multi-programming

Long termLong term

Medium termMedium term

Short termShort term

I/OI/O

Page 21: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Long Term SchedulingLong Term Scheduling

Determines which programs are submitted Determines which programs are submitted for processingfor processing

i.e. controls the degree of multi-i.e. controls the degree of multi-programmingprogramming

Once submitted, a job becomes a process Once submitted, a job becomes a process for the short term schedulerfor the short term scheduler

(or it becomes a swapped out job for the (or it becomes a swapped out job for the medium term scheduler)medium term scheduler)

Page 22: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Medium Term SchedulingMedium Term Scheduling

Part of the swapping function (later…)Part of the swapping function (later…)

Usually based on the need to manage Usually based on the need to manage multi-programmingmulti-programming

If no virtual memory, memory If no virtual memory, memory management is also an issuemanagement is also an issue

Page 23: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Short Term SchedulerShort Term Scheduler

DispatcherDispatcher

Fine grained decisions of which job to Fine grained decisions of which job to execute nextexecute next

i.e. which job actually gets to use the i.e. which job actually gets to use the processor in the next time slotprocessor in the next time slot

Page 24: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Scheduling ExampleScheduling Example

Page 25: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Key Elements of O/SKey Elements of O/S

Page 26: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Process SchedulingProcess Scheduling

Page 27: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Memory ManagementMemory Management

Uni-programUni-program Memory split into twoMemory split into two One for Operating System (monitor)One for Operating System (monitor) One for currently executing programOne for currently executing program

Multi-programMulti-program ““User” part is sub-divided and shared among User” part is sub-divided and shared among

active processesactive processes

Page 28: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

SwappingSwapping

Problem: I/O is so slow compared with Problem: I/O is so slow compared with CPU that even in multi-programming CPU that even in multi-programming system, CPU can be idle most of the timesystem, CPU can be idle most of the time

Solutions:Solutions: Increase main memory Increase main memory

ExpensiveExpensive

Leads to larger programsLeads to larger programs SwappingSwapping

Page 29: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

What is Swapping?What is Swapping?

Long term queue of processes stored on diskLong term queue of processes stored on disk

Processes “swapped” in as space becomes Processes “swapped” in as space becomes availableavailable

As a process completes it is moved out of main As a process completes it is moved out of main memorymemory

If none of the processes in memory are ready If none of the processes in memory are ready (i.e. all I/O blocked)(i.e. all I/O blocked) Swap out a blocked process to intermediate queueSwap out a blocked process to intermediate queue Swap in a ready process or a new processSwap in a ready process or a new process But swapping is an I/O process…But swapping is an I/O process…

Page 30: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Use of Use of SwappingSwapping

Page 31: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

PagingPaging

Split memory into equal sized, small chunks -page Split memory into equal sized, small chunks -page framesframes

Split programs (processes) into equal sized small Split programs (processes) into equal sized small chunks - pageschunks - pages

Allocate the required number page frames to a Allocate the required number page frames to a processprocess

Operating System maintains list of free framesOperating System maintains list of free frames

A process does not require contiguous page A process does not require contiguous page framesframes

Use page table to keep trackUse page table to keep track

Page 32: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Allocation of Free FramesAllocation of Free Frames

Page 33: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Logical and Physical Addresses Logical and Physical Addresses - Paging- Paging

Page 34: Chapter 11: Operating System Support Dr Mohamed Menacer Taibah University 2007-2008

Virtual MemoryVirtual Memory

Demand pagingDemand paging Do not require all pages of a process in memoryDo not require all pages of a process in memory Bring in pages as requiredBring in pages as required

Page faultPage fault Required page is not in memoryRequired page is not in memory Operating System must swap in required pageOperating System must swap in required page May need to swap out a page to make spaceMay need to swap out a page to make space Select page to throw out based on recent historySelect page to throw out based on recent history