Upload
bryce-parrish
View
216
Download
0
Tags:
Embed Size (px)
Citation preview
Chapter 11:Chapter 11:Operating System Operating System
SupportSupport
Dr Mohamed MenacerDr Mohamed MenacerTaibah UniversityTaibah University
2007-20082007-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
Layers and Views of a Computer SystemLayers and Views of a Computer System
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
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
°°
Layers and Views of a Computer SystemLayers and Views of a Computer System
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
O/S as a Resource ManagerO/S as a Resource Manager
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)
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
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
Memory Layout for Resident MonitorMemory Layout for Resident Monitor
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
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
Single ProgramSingle Program
Multi-Programming with Multi-Programming with Two ProgramsTwo Programs
Multi-Programming with Multi-Programming with Three ProgramsThree Programs
UtilizationUtilization
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
SchedulingScheduling
Key to multi-programmingKey to multi-programming
Long termLong term
Medium termMedium term
Short termShort term
I/OI/O
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)
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
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
Scheduling ExampleScheduling Example
Key Elements of O/SKey Elements of O/S
Process SchedulingProcess Scheduling
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
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
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…
Use of Use of SwappingSwapping
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
Allocation of Free FramesAllocation of Free Frames
Logical and Physical Addresses Logical and Physical Addresses - Paging- Paging
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