Page 257 - DCAP103_Principle of operating system
P. 257

Principles of Operating Systems



                   Notes         7.6.7 Three Rules of Swap Space Allocation
                                 Start at the lowest priority swap device or file system. The lower the number, the higher priority;
                                 that is, space is taken from a system with a zero priority before it is taken from a system with
                                 a one priority.
                                 If multiple devices have the same priority, swap space is allocated from the devices in a round-
                                 robin fashion. Thus, to interleave swap requests between a number of devices, the devices should
                                 be assigned the same priority. Similarly, if multiple file systems have the same priority, requests
                                 for swap are interleaved between the file systems.
                                 In the figure below swap requests are initially interleaved between the two swap devices at
                                 priority 0.
                                 If a device and a file system have the same swap priority, all the swap space from the device is
                                 allocated before any file-system swap space. Thus, the device at priority 1 will be filled before
                                 swap is allocated from the file system at priority 1.
                                                        Figure 7.7: Choosing a Swap Location

                                                swdev_pri           swdevt                swaptab
                                              0
                                              1                      dev1
                                                                     dev2
                                             10                      dev3


                                                 swfs_pri
                                              0                     fswdevt
                                              1
                                                                     fs1

                                             10

                                 7.6.7.1 Swap Space Structures
                                 Swapping is accomplished on HP-UX using the following data structures.

                                    •  Device swap priority array (swdev_pri[ ]), used to link together swap devices with the
                                      same priority. That is, the entry in swdev_pri[n] is the head of a list of swap devices having
                                      priority n. The first field in swdev_pri[ ] structure is the head of the list; the sw_next field
                                      in the swdevt[ ] structure links each device into the appropriate priority list.

                                    •  File system swap priority array (swfs_pri[ ]), which serves the same purpose as swdev_pri[ ],
                                      but for file system swap priority.
                                    •  Device swap table (struct swdevt), defined in conf.h to establish the fundamental swap
                                      device information.
                                    •  File system swap table (struct fswdevt), defined in swap.h for supplimentary file-system
                                      swap.
                                    •  Swap table of available chunks (struct swaptab), which keeps track of the available free
                                      pages of swap space.
                                    •  Mapping of swap pages (struct swapmap), whose entries together with swaptab combine
                                      for a swap disk block descriptor. The following table details the elements of the struct
                                      swdevt.



        250                               LOVELY PROFESSIONAL UNIVERSITY
   252   253   254   255   256   257   258   259   260   261   262