Page 158 - DCAP103_Principle of operating system
P. 158

Unit 5: Memory Management



                                                                                                  Notes
                         Figure 5.2: Dynamic Relocation using a Relocation Register







                                               Relocation
                                                registor
                                                14000
                                     Logical              Physical
                                     address              address
                          CPU                                         Memory
                                      346                  14346






                                                 MMU



            5.3 Swapping


            A  process  needs  to  be  in  memory  to  be  executed.  A  process,  however,  can  be  swapped
            temporarily  out  of  memory  to  a  backing  store,  and  then  brought  back  into  memory  for
            continued execution. For example, assume a multiprogramming environment with a round-
            robin CPU-scheduling algorithm. When a quantum expires, the memory manager will start
            to swap out the process that just finished, and to swap in another process to the memory
            space that has been freed (Figure 5.3). In the meantime, the CPU scheduler will allocate a
            time slice to some other process in memory. When each process finishes its quantum, it will
            be swapped with another process. Ideally, the memory manager can swap processes fast
            enough that some processes will be in memory, ready to execute, when the CPU scheduler
            wants to reschedule the CPU. The quantum must also be sufficiently large that reasonable
            amounts of computing are done between swaps.

                    Figure 5.3: Swapping of Two Processes using a Disk as a Backing Store






























                                             LOVELY PROFESSIONAL UNIVERSITY                                   151
   153   154   155   156   157   158   159   160   161   162   163