Presentation on theme: "Operating System Support Focus on Architecture"— Presentation transcript:
1 Operating System Support Focus on Architecture Chapter 8Operating System SupportFocus on Architecture
2 Functions of Operating System Managing ResourcesAccess to System UtilitiesAccess to filesAccess to I/O devicesManaging Interrupts & Bus ControlError detection and responseAccountingScheduling Processes (or tasks)Program creationProgram executionI/O ProcessingManaging Memory UtilizationPartitioning,Paging,Virtual memory,Segmentation
3 Types of Operating Systems InteractiveBatchUni-taskingMulti-taskingReal-Time
4 Batch Operating System Model Jobs are batched in queueMonitor handles schedulingMonitor controls sequence ofevents to process batchWhen one job is finished,control returns to Monitorwhich loads next job
5 Desirable Hardware Support for OS Memory protectionTo protect the Monitor & UtilitiesTimerTo prevent a job monopolizing the systemPrivileged instructionsOnly executed by Monitore.g. I/O, filesInterruptsAllows for relinquishing and regaining controlDMAAllows for optimizing bus usage
6 The Case for Multi-programmed Batch Systems I/O devices are very slow Waiting is inefficient use of computerWhen one program is waiting for I/O, another can use the CPU
16 Note: Memory size implications Memory ManagementUni-programmingMemory split into twoOne for Operating System (monitor)One for currently executing programMulti-programming“User” part is sub-divided and shared among active processesNote: Memory size implications- 16 bits 64K memory addresses- 24 bits 16M memory addresses- 32 bits 4G memory addresses
17 SwappingProblem: I/O is so slow compared with CPU that even in multi-programming system, CPU can be idle most of the timeSolutions:Increase amount of main memoryExpensiveSwapping
18 What is Swapping? Long term queue of processes stored on disk Processes “swapped” in as space becomes availableAs a process completes it is moved out of main memoryIf none of the processes in memory are ready (i.e. all I/O blocked)Swap out a blocked process to intermediate queueSwap in a ready process or a new processBut swapping is an I/O process…Isn’t I/O slow?So why does swapping make sense ?
20 Partitioning Partitioning: May not be equal size: Splitting memory into sections to allocate to processes(including Operating System!)Fixed-sized partitionsPotentially a lot of wasted memoryVariable-sized partitionsProcess is stored into smallest reasonable “hole”Dynamic partitionsno room for additional memory allocationmemory leak – need periodic coalescing, or– need periodic compaction
23 Relocation Challenges Can’t expect that process will load into the same place in memory as last timeInstructions contain addressesLocations of dataAddresses for instructions (branching)Logical address - relative to beginning of programPhysical address - actual location in memory(this time)A Solution:Use Base AddressAutomatic (hardware) Conversion
24 - A process does not require contiguous page frames PagingSplit memory into equal sized, small chunks- page framesOperating System maintains list of free framesThen:Split programs (processes) into equal sized small chunks– pagesAllocate the required number page frames to a process- A process does not require contiguous page frames- Each process has its own page table
27 Paging Implementations Demand pagingDo not require all pages of a process in memoryBring in pages as requiredPage faultRequired page is not in memoryOperating System must swap in required pageMay need to swap out a page to make spacePerhaps select page to throw out based on recent history
28 ThrashingToo many processes in too little memoryOperating System spends all its time swappingLittle or no real work is doneSolutionsGood page replacement algorithmsReduce number of processes runningAdd more memory
29 Virtual Memory Differentialtions: Implications: We do not need all of a process in memory for it to run - We can swap in pages as requiredSo - we can now run processes that are bigger than total memory available!Differentialtions:Main memory is called real memoryUser/programmer can see much bigger memory space - virtual memoryImplications:Tables can become huge that can’t fit into memory – need multiple level tables – yech!
31 Translation Lookaside Buffer Every virtual memory reference causes two physical memory accessFetch page table entryFetch dataUse special cache for page table(s)
32 TLB and Cache Operation (special Cache for tables)
33 Segmentation What is it? Segmentation is visible to the programmer - Paging is not (usually) visible to theprogrammerUsually different segments allocated to program and dataMay be a number of program and data segments, e.g. to support protection levels, priority levels, organization, flexibility, etc.
34 Advantages of Segmentation Simplifies handling of growing data structuresAllows programs to be altered and recompiled independently, without re-linking and re-loadingLends itself to sharing among processesLends itself to protectionSome systems combine segmentation with paging
35 Scheduling: OS Review uni-programming multi-programming time-sharing long-term scheduler (queue of all jobs potentially schedulable)short-term scheduler (queue of processes that are ready to execute)medium-term scheduling (queue of jobs that can reside in memory)blocked monitoring (queue of processes blocked for resources)new – ready – running – blocked – exit state machineMemory management:partitioningpaging – frames, pages, page fault, page table, logical/physical addrvirtual memory – inverted page table, Translation Lookaside Buffersegmentation
36 Power PC – Motorola & IBM Pentium and Power PCPentium – IntelPower PC – Motorola & IBMA 32 bit memory address space is 4 G BytesA 46 bit memory address space is 64 T Bytes1.25 terabytes has been claimed as the capacity of a human being's functional memory (according to Raymond Kurzweil).A Holographic Versatile Disc (HVD) can hold up to 3.9 terabytes.One hour of uncompressed Ultra High Definition Video (UHDV) consumes approximately 11.5 terabytes of data.The U.S. Library of Congress has claimed that "as of December 31, 2005, the Library has collected more than 40 terabytes of data."A Protein-coated disc (PCD) can hold 50 terabytes of data.A 64 bit memory address space is ? (Who cares!)The point is that it is not clear to me why we care for some at least some years to come.
37 Pentium II (Uses hardware for segmentation & paging) Unsegmented, unpagedvirtual address = physical addressUsed in Low complexity, High performance systemsUnsegmented, pagedMemory viewed as paged linear address spaceProtection and management via paging (Ex: Berkeley UNIX)Segmented, unpagedCollection of local address spacesProtection to single byte level, Translation table needed is on chip when segment is in memory, provide predictable access timesSegmented, pagedSegmentation used to define logical memory partitions subject to access controlPaging manages allocation of memory within partitions (Ex: Unix System V)
38 Pentium II Address Translation Mechanism “Segment” uses 2 bits to provide 4 levels of protection, typically:0: OS kernel, 1: OS, 2: apps needing special security, 3: general apps
39 Segmentation may be disabled Two level page table lookup Pentium II PagingSegmentation may be disabledIn which case linear address space is usedTwo level page table lookupFirst, page directory1024 entries maxSplits 4G linear memory into 1024 page groups of 4MbyteEach page table has 1024 entries corresponding to 4Kbyte pagesCan use one page directory for all processes, one per process or mixturePage directory for current process always in memoryUse TLB holding 32 page table entriesTwo page sizes available 4k or 4M
41 PowerPC Memory Management Hardware 32 bit – paging with simple segmentationor 64 bit paging with more powerful segmentationOr, both do block address translationMap 4 large blocks of instructions & 4 of memory to bypass paginge.g. OS tables or graphics frame buffers32 bit effective address12 bit byte selector=4kbyte pages16 bit page id64k pages per segment4 bits indicate one of 16 segment registersSegment registers under OS control