Page 128 - DCAP403_Operating System
P. 128

Unit 7: Memory Management




          When applications begin to be loaded into memory, they are loaded in block sizes determined   Notes
          by the operating system. If the block size is 2 kilobytes, then every process that is loaded will be
          given a chunk of memory that is a multiple of 2 kilobytes in size. Applications will be loaded in

          these fixed block sizes, with the blocks starting and ending on boundaries established by words
          of 4 or 8 bytes. These blocks and boundaries help to ensure that applications won’t be loaded
          on top of one another’s space by a poorly calculated bit or two. With that ensured, the larger
          question is what to do when the 500-kilobyte application space is fi lled.
          In most computers, it’s possible to add memory beyond the original capacity. For example, you

          might expand RAM from 1 to 2 megabytes. This works fine, but tends to be relatively expensive.
          It also ignores a fundamental fact of computing - most of the information that an application
          stores in memory is not being used at any given moment. A processor can only access memory
          one location at a time, so the vast majority of RAM is unused at any moment. Since disk space
          is cheap compared to RAM, then moving information in RAM to hard disk can greatly expand
          RAM space at no cost. This technique is called virtual memory management.
          Disk storage is only one of the memory types that must be managed by the operating system, and
          is the slowest. Ranked in order of speed, the types of memory in a computer system are:
          1.   High-speed cache: This is fast, relatively small amounts of memory that are available to
               the CPU through the fastest connections. Cache controllers predict which pieces of data
               the CPU will need next and pull it from main memory into high-speed cache to speed up
               system performance.

          2.   Main memory: This is the RAM that you see measured in megabytes when you buy a
               computer.
          3.   Secondary memory: This is most often some sort of rotating magnetic storage that keeps
               applications and data available to be used, and serves as virtual RAM under the control of
               the operating system.
          The operating system must balance the needs of the various processes with the availability of the
          different types of memory, moving data in blocks (called pages) between available memory as
          the schedule of processes dictates.

          Systems for managing memory can be divided into two categories: the system of moving
          processes back and forth between main memory and disk during execution (known as swapping
          and paging) and the process that does not do so (that is, no swapping and ping).

                                    Figure 7.1: Memory Management
                                       The CPU sends virtual
                              CPU      addresses to the MMU
                              card
                       CPU
                                      Memory                 Disk
                                     management  Memory    controller
                                        unit



                                                                   Bus
                           The MMU sends physical
                           addresses to the memory





              Task    What is the concept of primary and secondary memory?




                                           LOVELY PROFESSIONAL UNIVERSITY                                   121
   123   124   125   126   127   128   129   130   131   132   133