operating systems { week 12a}

Download Operating Systems { week  12a}

Post on 13-Feb-2016




0 download

Embed Size (px)


Rensselaer Polytechnic Institute CSCI-4210 Operating Systems David Goldschmidt, Ph.D. Operating Systems { week 12a}. Hierarchical storage architecture. very fast. very small. volatile. non-volatile. very slow. very large. Von Neumann architecture. - PowerPoint PPT Presentation


Chapter 1: Information Technology

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

very smallvery largevery fastvery slowvolatilenon-volatile

Von Neumann architectureBased on the von Neumann architecture, data and program instructionsexist in physical memoryRepeatedly performfetch-decode-executecyclesThe execute partoften results in datafetch and store operationsphysical memory

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 Dynamic loading and linkingUsing dynamic loading, external libraries are not loaded when a process startsLibraries are stored on disk in relocatable formLibraries loaded into memory only when needed

Using dynamic linking, external libraries can be preloaded into shared memoryWhen a process calls a library function, thecorresponding physical address is determinedContiguous memory allocation (i)Main memoryis partitionedand allocatedto residentoperating systemand user processes

fixed partitioning scheme

Contiguous memory allocation (ii)A pair of base and limitregisters define thelogical address space Also known asrelocation registers

Contiguous memory allocation (iii)The CPU generates logical memory addressesA Memory-Management Unit (MMU)maps logical memory addressesto the physical address space

User programs never seephysical memory addressesContiguous memory allocation (iv)Hardware protects against memory access outside of a processs valid memory space

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

Fragmentation (i)Memory 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

Process 3Process 6Process 12Process 7Fragmentation (ii)Reduce external fragmentation bycompaction or defragmentation Rearrange memory contents to organizeall free memory blocks together intoone large contiguous blockCompaction is possible only ifrelocation is dynamic and isdone at execution timeCompaction is expensiveOSProcess 5Process 8Process 2Process 9

Process 3Process 6Process 12Process 7Process 3Process 6Process 12Process 7Process 9