ICS 143 – Principles of Operating SystemsLectures 13-14 – Memory Management: Mai

ICS 143 - Principles of Operating SystemsLectures 13-14 - Memory Management: Mai www.phwiki.com

ICS 143 – Principles of Operating SystemsLectures 13-14 – Memory Management: Mai

Schuler, Charli, Contributing Editor has reference to this Academic Journal, PHwiki organized this Journal ICS 143 – Principles of Operating SystemsLectures 13-14 – Memory Management: Main MemoryProf. Ardalan Amiri SaniProf. Nalini Venkatasubramanianardalan@uci.edunalini@ics.uci.eduOutlineBackgroundLogical versus Physical Address SpaceSwappingContiguous AllocationPagingSegmentationSegmentation with PagingBackgroundProgram must be brought into memory in addition to placed within a process as long as it to be executed.Input Queue – collection of processes on the disk that are waiting to be brought into memory as long as execution.User programs go through several steps be as long as e being executed.

Anthem Institute-Springfield PA www.phwiki.com

This Particular University is Related to this Particular Journal

Virtualizing ResourcesPhysical Reality: Processes/Threads share the same hardwareNeed to multiplex CPU (CPU Scheduling)Need to multiplex use of Memory (Today)Why worry about memory multiplexingThe complete working state of a process in addition to /or kernel is defined by its data in memory ( in addition to registers)Consequently, cannot just let different processes use the same memoryProbably don’t want different processes to even have access to each other’s memory (protection)Important Aspects of Memory MultiplexingControlled overlap:Processes should not collide in physical memoryConversely, would like the ability to share memory when desired ( as long as communication)Protection:Prevent access to private memory of other processesDifferent pages of memory can be given special behavior (Read Only, Invisible to user programs, etc)Kernel data protected from user programsTranslation: Ability to translate accesses from one address space (virtual) to a different one (physical)When translation exists, process uses virtual addresses, physical memory uses physical addressesNames in addition to BindingSymbolic names Logical names Physical namesSymbolic Names: known in a context or pathfile names, program names, printer/device names, user namesLogical Names: used to label a specific entityinodes, job number, major/minor device numbers, process id (pid), uid, gid Physical Names: address of entityinode address on disk or memoryentry point or variable addressPCB address

Binding of instructions in addition to data to memoryAddress binding of instructions in addition to data to memory addresses can happen at three different stages.Compile time: If memory location is known a priori, absolute code can be generated; must recompile code if starting location changes.Load time:Must generate relocatable code if memory location is not known at compile time.Execution time:Binding delayed until runtime if the process can be moved during its execution from one memory segment to another. Need hardware support as long as address maps (e.g. base in addition to limit registers).Binding time tradeoffsEarly bindingcompiler – produces efficient codeallows checking to be done earlyallows estimates of running time in addition to spaceDelayed bindingLinker, loaderproduces efficient code, allows separate compilationportability in addition to sharing of object codeLate bindingVM, dynamic linking/loading, overlaying, interpretingcode less efficient, checks done at runtimeflexible, allows dynamic reconfigurationMulti-step Processing of a Program as long as ExecutionPreparation of a program as long as execution involves components at:Compile time (i.e., “gcc”)Link/Load time (unix “ld” does link)Execution time (e.g. dynamic libs)Addresses can be bound to final values anywhere in this pathDepends on hardware support Also depends on operating systemDynamic LibrariesLinking postponed until executionSmall piece of code, stub, used to locate appropriate memory-resident library routineStub replaces itself with the address of the routine, in addition to executes routine

Dynamic LoadingRoutine is not loaded until it is called. Better memory-space utilization; unused routine is never loaded.Useful when large amounts of code are needed to h in addition to le infrequently occurring cases.No special support from the operating system is required; implemented through program design.Dynamic LinkingLinking postponed until execution time.Small piece of code, stub, used to locate the appropriate memory-resident library routine.Stub replaces itself with the address of the routine, in addition to executes the routine.Operating system needed to check if routine is in processes’ memory address.OverlaysKeep in memory only those instructions in addition to data that are needed at any given time.Needed when process is larger than amount of memory allocated to it.Implemented by user, no special support from operating system; programming design of overlay structure is complex.

OverlayingLogical vs. Physical Address SpaceThe concept of a logical address space that is bound to a separate physical address space is central to proper memory management.Logical Address: or virtual address – generated by CPUPhysical Address: address seen by memory unit.Logical in addition to physical addresses are the same in compile time in addition to load-time binding schemesLogical in addition to physical addresses differ in execution-time address-binding scheme.Memory Management Unit (MMU) Hardware device that maps virtual to physical address.In MMU scheme, the value in the relocation register is added to every address generated by a user process at the time it is sent to memory.The user program deals with logical addresses; it never sees the real physical address.

SwappingA process can be swapped temporarily out of memory to a backing store in addition to then brought back into memory as long as continued execution.Backing Store – fast disk large enough to accommodate copies of all memory images as long as all users; must provide direct access to these memory images.Roll out, roll in – swapping variant used as long as priority based scheduling algorithms; lower priority process is swapped out, so higher priority process can be loaded in addition to executed.Major part of swap time is transfer time; total transfer time is directly proportional to the amount of memory swapped.Modified versions of swapping are found on many systems, i.e. UNIX in addition to Microsoft Windows.Schematic view of swappingContiguous AllocationMain memory usually into two partitionsResident Operating System, usually held in low memory with interrupt vector.User processes then held in high memory.Single partition allocationRelocation register scheme used to protect user processes from each other, in addition to from changing OS code in addition to data.Relocation register contains value of smallest physical address; limit register contains range of logical addresses – each logical address must be less than the limit register.

Relocation RegisterBase register (ba)Logicaladdress(ma)Physicaladdress(pa)Base registerMemoryCPUpa = ba + maRelocation in addition to Limit RegistersFixed partitions

Contiguous Allocation (cont.)Multiple partition AllocationHole – block of available memory; holes of various sizes are scattered throughout memory.When a process arrives, it is allocated memory from a hole large enough to accommodate it.Operating system maintains in as long as mation aboutallocated partitionsfree partitions (hole)Contiguous Allocation exampleOSOSOSOSProcess 5Process 5Process 5Process 5Process 2Process 2Process 2Process 2Process 8Process 9Process 9Process 10Dynamic Storage Allocation ProblemHow to satisfy a request of size n from a list of free holes.First-fitallocate the first hole that is big enoughBest-fitAllocate the smallest hole that is big enough; must search entire list, unless ordered by size. Produces the smallest leftover hole.Worst-fitAllocate the largest hole; must also search entire list. Produces the largest leftover hole.First-fit in addition to best-fit are better than worst-fit in terms of speed in addition to storage utilization.

Schuler, Charli TotalBeauty.com Contributing Editor www.phwiki.com

FragmentationExternal fragmentationtotal memory space exists to satisfy a request, but it is not contiguous.Internal fragmentationallocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used.Reduce external fragmentation by compactionShuffle memory contents to place all free memory together in one large blockCompaction is possible only if relocation is dynamic, in addition to is done at execution time.I/O problem – (1) latch job in memory while it is in I/O (2) Do I/O only into OS buffers.Fragmentation exampleCompaction

PagingLogical address space of a process can be non-contiguous; process is allocated physical memory wherever the latter is available.Divide physical memory into fixed size blocks called framessize is power of 2, 512 bytes – 8KDivide logical memory into same size blocks called pages.Keep track of all free frames.To run a program of size n pages, find n free frames in addition to load program.Set up a page table to translate logical to physical addresses.Note:: Internal Fragmentation possible!!Address Translation SchemeAddress generated by CPU is divided into:Page number(p)used as an index into page table which contains base address of each page in physical memory.Page offset(d)combined with base address to define the physical memory address that is sent to the memory unit.Address Translation ArchitectureCPU::fpfddPhysicalMemoryp

‹ ›MULTICS address translation scheme

Schuler, Charli Contributing Editor

Schuler, Charli is from United States and they belong to TotalBeauty.com and they are from  Santa Monica, United States got related to this Particular Journal. and Schuler, Charli deal with the subjects like Beauty; Cosmetics; Women’s Interest

Journal Ratings by Anthem Institute-Springfield

This Particular Journal got reviewed and rated by Anthem Institute-Springfield and short form of this particular Institution is PA and gave this Journal an Excellent Rating.