Page 142 - DCAP403_Operating System
P. 142

Unit 7: Memory Management




          virtual memory is the single-user system. Consider a single-user system with 128 KB memory   Notes
          composed of pages of size 1 KB. Thus, there are 128 frames. The operating system may take 35
          KB, leaving 93 frames for the user process. Under pure demand paging, all 93 frames would
          initially be put on the free-frame list. When a user process started execution, it would generate

          a sequence of page faults. The first 93 page faults would all get free frames from the free-frame
          list. When the free-frame list was exhausted, a page replacement algorithm would be used to
          select one of the 93 in-memory pages to be replaced with the ninety-fourth, and so on. When the
          process terminated, the 93 frames would once again be placed on the free-frame list.
          There are many variations on this simple strategy. You can require that the operating system
          allocate all its buffer and table space from the free-frame list. When this space is not in use by the
          operating system, it can be used to support user paging. You can try to keep three free frames
          reserved on the free-frame list at all times. Thus, when a page fault occurs, there is a free frame
          available to page into. While the page swap is taking place, a replacement can be selected, which
          is then written to the disk as the user process continues to execute.
          Other variants are also possible, but the basic strategy is clear. The user process is allocated any
          free frame.




              Task    Least frequency is calculated throughout the reference stream, and its value can
             be calculated in a various ways. Discuss those ways.

          7.12 Thrashing


          Thrashing happens when a hard drive has to move its heads over the swap area many times
          due to the high number of page faults. This happens when memory accesses are causing page
          faults as the memory is not located in main memory. The thrashing happens as memory pages
          are swapped out to disk only to be paged in again soon afterwards. Instead of memory access
          happening mainly in main memory, access is mainly to disk causing the processes to become
          slow as disk access is required for many memory pages and thus thrashing.
          The OS can reduce the effects of thrashing and improve performance by choosing a more suitable
          replacement strategy for pages. Having a replacement strategy that does not cause memory

          areas to be written to disk that have not modified since been retrieved reduces thrashing. Using
          replacement strategies that allow little used rarely accessed pages to remain in memory while the
          most required pages are swapped in and out.
          Thrashing is a situation where large amounts of computer resources are used to do a minimal
          amount of work, with the system in a continual state of resource contention. Once started,
          thrashing is typically self-sustaining until something occurs to remove the original situation that
          led to the initial thrashing behavior.
          Usually thrashing refers to two or more processes accessing a shared resource repeatedly
          such that serious system performance degradation occurs because the system is spending a
          disproportionate amount of time just accessing the shared resource. Resource access time may
          generally be considered as wasted, since it does not contribute to the advancement of any process.
          This is often the case when a CPU can process more information than can be held in available
          RAM; consequently the system spends more time preparing to execute instructions than actually
          executing them.

          Concept of Thrashing

          If the number of frames allocated to a low priority process is lower than the minimum number
          required by the computer architecture then in this case we must suspend the execution of this



                                           LOVELY PROFESSIONAL UNIVERSITY                                   135
   137   138   139   140   141   142   143   144   145   146   147