zoukankan      html  css  js  c++  java
  • Partitioning

    COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION

    The simplest scheme for partitioning available memory is to use
    fixed-size partitions,
    as shown in Figure 8.13. Note that, although the partitions are of fixed size,
    they need not be of equal size. When a process is brought into memory, it is placed
    in the smallest available partition that will hold it.
     
    Even with the use of unequal fixed-size partitions, there will be wasted memory.
    In most cases, a process will not require exactly as much memory as provided by
    the 
    partition. For example, a process that requires 3M bytes of memory would be placed
    in the 4M partition of Figure 8.13b, wasting 1M that could be used by another process.
     
    A more efficient approach is to use variable-size partitions. When a process is
    brought into memory, it is allocated exactly as much memory as it requires and no more.
     
     
    Example 8.2
    An example, using 64 Mbytes of main memory, is shown in Figure 8.14.
    Initially, main memory is empty, except for the OS (a). The first three processes are loaded
    in, starting where the OS ends and occupying just enough space for each process (b, c, d).
    This leaves a “hole” at the end of memory that is too small for a fourth process. At some
    point, none of the processes in memory is ready. The OS swaps out process 2 (e), which
    leaves sufficient room to load a new process, process 4 (f). Because process 4 is smaller
    than process 2, another small hole is created. Later, a point is reached at which none of the
    processes in main memory is ready, but process 2, in the Ready-Suspend state, is available.
    Because there is insufficient room in memory for process 2, the OS swaps process 1 out (g)
    and swaps process 2 back in (h).
     
     
     
    As this example shows, this method starts out well, but eventually it leads to a
    situation in which there are a lot of small holes in memory. As time goes on, mem-
    ory becomes more and more fragmented, and memory utilization declines. One
    technique for overcoming this problem is
    compaction
    : From time to time, the OS
    shifts the processes in memory to place all the free memory together in one block.
    This is a time-consuming procedure, wasteful of processor time.
     
    Before we consider ways of dealing with the shortcomings of partitioning, we
    must clear up one loose end. Consider Figure 8.14; it should be obvious that a proc-
    ess is not likely to be loaded into the same place in main memory each time it is
    swapped in. Furthermore, if compaction is used, a process may be shifted while in
    main memory. A process in memory consists of instructions plus data. The instruc-
    tions will contain addresses for memory locations of two types:
    Addresses of data items
    Addresses of instructions, used for branching instruction
     
    But these addresses are not fixed. They will change each time a process is
    swapped in. To solve this problem, a distinction is made between logical addresses
    and physical addresses. A logical address is expressed as a location relative to the
    beginning of the program. Instructions in the program contain only logical addresses.
    A physical address is an actual location in main memory. When the processor exe-
    cutes a process, it automatically converts from logical to physical address by adding
    the current starting location of the process, called its base address, to each logical
    address. This is another example of a processor hardware feature designed to meet
    an OS requirement. The exact nature of this hardware feature depends on the mem-
    ory management strategy in use. We will see several examples later in this chapter.
  • 相关阅读:
    USACO1.3.3Calf Flac
    USACO1.3.1Mixing Milk
    USACO1.3.2Barn Repair
    USACO2.1.4Healthy Holsteins
    USACO1.5.2Prime Palindromes
    USACO1.4.2The Clocks
    USACO2.1.2Ordered Fractions
    PHP关联数组教程
    你的服务器没有正确响应Token验证的解决方法
    微信公众平台消息接口开发(10)语音触发(非识别)
  • 原文地址:https://www.cnblogs.com/rsapaper/p/6216600.html
Copyright © 2011-2022 走看看