operating systems { week 12b }

Download Operating Systems { week 12b }

Post on 14-Feb-2016




0 download

Embed Size (px)


Rensselaer Polytechnic Institute CSCI-4210 Operating Systems David Goldschmidt, Ph.D. Operating Systems { week 12b }. Hierarchical storage architecture. very fast. very small. volatile. non-volatile. very slow. very large. Main memory (i). - PowerPoint PPT Presentation


Chapter 1: Information Technology

Operating Systems{week 12b}Rensselaer Polytechnic InstituteCSCI-4210 Operating SystemsDavid Goldschmidt, Ph.D.Hierarchical storage architecture

very smallvery largevery fastvery slowvolatilenon-volatile

Main memory (i)Locations in memoryare identified bymemory addresses When compiled, programsconsist of relocatable code Other compiled modulesalso consist ofrelocatable codesymbolic addressesin source coderelative addressesin object code

Main memory (ii)At load time, anyadditional librariesalso consist ofrelocatable code physical addressesgenerated by loader

Main memory (iii)At run time, memoryaddresses of all objectfiles are mapped to asingle memory spacein physical memory

Contiguous memory allocationA pair of base and limitregisters define thelogical address space Also known asrelocation registers Dynamic partitioningVariable-length or dynamic partitions:When a new process enters the system, the process is allocated to a single contiguous block

The operating system maintains a list of allocated partitions and free partitionsOSProcess 5Process 8Process 2OSProcess 5Process 2OSProcess 5Process 2Process 9OSProcess 5Process 9Process 2Process 1Placement algorithmsHow can we place new process Pi in memory?First-fit algorithm: allocate the first free blockthats large enough to accommodate Pi Best-fit algorithm: allocate thesmallest free block thats largeenough to accommodate Pi Next-fit algorithm: allocate thenext free block, searching from last allocated blockWorst-fit algorithm: allocate the largest free blockthats large enough to accommodate Pi

FragmentationMemory is wasted due to fragmentation,which can cause performance issuesInternal fragmentation is wasted memorywithin a partition or process memoryExternal fragmentation can reducethe number of runnable processesTotal memory space exists to satisfya memory request, but memory isnot contiguousOSProcess 5Process 8Process 2Process 3Process 6Process 12Process 7Process 9

Noncontiguous allocation (i)A noncontiguous memory allocation scheme avoids the external fragmentation problemSlice up physical memory intofixed-sized blocks called frames Sizes typically range from 29 to 214 Slice up logical memory intofixed-sized blocks called pages Allocate pages into framesNote that frame size equals page size

Noncontiguous allocation (ii)When a process of size n pages is ready to run, operating system finds n free frames

The OS keepstrack of pagesvia a page table main memoryprocess Pi== in use== freePaging via a page table (i)

Page tables map logical memoryaddresses to physical memoryaddressesPaging via a page table (ii)Example process Pi needs 16MB oflogical memoryPage size is 4MBLogical memory ismapped to a 32MBphysical memoryFrame size is 4MB

binary 0 ==> 000000 4 ==> 000100 8 ==> 00100012 ==> 00110016 ==> 01000020 ==> 01010024 ==> 01100028 ==> 011100Allocating a new process

Address translation (i)Every logical address issliced into two distinctcomponents:Page number (p): used as an index into thepage table to obtain the base physical memory addressPage offset (d): combined with the base address to identify the physical memory addresspage numberpage offsetpdAddress translation (ii)Covers a logical addressspace of size 2m withpage size 2n

page numberpage offsetpd(m n)(n)Address translation (iii)

Address translation (iv)

12The page table is in main memoryEvery memory access request actually requires two memory accesses:Translation look-aside buffer

Use page tablecaching at thehardware levelto speed addresstranslation

Hardware-leveltranslation look-aside buffer(TLB)Effective memory access timeGiven:Memory access time is 100 nanosecondsTLB access time is 20 nanosecondsTLB hit ratio is 80%

The effective memory-access time (EMAT) is0.80 x 120 ns + 0.20 x 220 ns = 140 nsWhat is the effective memory-access timegiven a hit ratio of 99%? 50%?Multilevel page tablesFor large page tables, usemultiple page table levelsSlice up the logical addressinto multiple page indicators

SwappingProcesses in the ready queue have memory images waiting on diskProcesses are swapped in andout of memoryCan suffer from slow data transfer times