资源预览内容
第1页 / 共69页
第2页 / 共69页
第3页 / 共69页
第4页 / 共69页
第5页 / 共69页
第6页 / 共69页
第7页 / 共69页
第8页 / 共69页
第9页 / 共69页
第10页 / 共69页
亲,该文档总共69页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
1,Memory Management,BTT205 Operating System,Lecture - 6,Outline,Memory ManagementRequirements of Memory ManagementMemory PartitioningBasic blocks of memory management,Memory management,The task of subdivision is carried out dynamically by the OS and this is known as Memory Management.,Memory Management Requirements,RelocationProtectionSharingLogical organisationPhysical organisation,Memory Management Requirements,RelocationThe programmer does not know where the program will be placed in memory when it is executed, Memory references must be translated to the actual physical memory addressWhen program loaded into memory the actual (absolute) memory locations are determinedA process may occupy different partitions which means different absolute memory locations during execution,6,ProtectionProtect each process against unwanted memory interference (accidental or deliberate)Implement by OS performing range check on each memory access for a processSharingMay want to share code and data between processesOS (and only OS) can provide this by overlapping memory space for 2 or more processes.,Memory Management Requirements,Memory Management Requirements,Memory Management Requirements,AddressingOS will need to know the location of Process Control Information and of the execution stack, as well as the entry point. Branch Instruction:Data Reference Instruction:,Memory Management Requirements,ProtectionProcesses should not be able to reference memory locations in another process without permission.Impossible to check absolute addresses at compile timeMust be checked at run timeSharingAllow several processes to access the same portion of memoryBetter to allow each process access to the same copy of the program rather than have their own separate copy,Memory management Requirements,Logical OrganizationMemory is organized linearlyPrograms are written in modulesDifferent degrees of protection given to modules (read-only, execute-only)Share modules among processesSegmentation helps herePhysical OrganizationCannot leave the programmer with the responsibility to manage memoryMemory available for a program plus its data may be insufficientProgrammer does not know how much space will be available,11,Partition,Division of physical memory into fixed sized regions. (Allows addresses spaces to be distinct = one user cant muck with another user, or the system.)The number of partitions determines level of multiprogramming. Partition is given to a process when its scheduled.Protection around each partition determined by bounds ( upper, lower ) base / limit.These limits are applied in hardware.,Partitioning,Early method of managing memoryWill clarify the later discussion of virtual memory if we look first at partitioningTypes of PartitioningFixed PartitioningDynamic Partitioning,Fixed Partitioning,Equal-size partitionsOperating system can swap a process out of a partition,Fixed Partitioning Problems,A program may not fit in a partition. The programmer must design the program with overlaysMain memory use is inefficient. Any program, no matter how small, occupies an entire partition.This is results in internal fragmentation.,15,Fragmentation Problem,Internal fragmentationUnused memory within a unit of allocationExternal fragmentationUnused memory between units of allocation,0,MAX,ProgramRs PAS,Program,Qs,PAS,Fragmentation Problem,Fixed-sized partitions (either equal or un-equal sized) we have the problem of fragmentation. Internal fragmentation A process has free memory within its allocation but cannot use it.Stack segment of a program needs to grow. There is free memory in the data segment but it cannot be used to grow the stack. The general problem is that you have free memory but cant use it. You also have the problem that a process can only as large as the largest partition. In particular, jobs cant be larger than the size of physical memory.,16,Fragmentation Problem,External fragmentation Cant use a partition even though its empty. For example, P needs a partition with 5 memory units. Q is using the only partition of that size. However, if partition 2 could be combined with Rs fragment, then wed have a 5 unit partition.(Assume partitions must start at addresses that are multiples of some constant and hence they cannot just start anywhere.),17,Solution Unequal Size Partitions,Lessens both problems but doesnt solve completelyPrograms up to 16M can be accommodated without overlaySmaller programs can be placed in smaller partitions, reducing internal fragmentation,Placement Algorithm,Equal-sizePlacement is trivial (no options)Unequal-sizeCan assign each process to the smallest partition within which it will fitQueue for each partitionProcesses are assigned in such a way as to minimize wasted memory within a partition,Remaining Problems with Fixed Partitions,The number of active processes is limited by the system I.E limited by the pre-determined number of partitionsA large number of very small process will not use the space efficientlyIn either fixed or variable length partition methods,
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号