Page 374 - DCAP103_Principle of operating system
P. 374

Unit 12: Processes and Threads in Windows



                                                                                                  Notes
                     Figure 12.13: The Various Page Lists and the Transitions between Them

























            Pages are moved between the working sets and the various lists by the working set manager
            and other kernel daemon threads. Let us examine the transitions. When the working set manager
            removes a page from a working set, the page goes on the bottom of the standby or modified
            list, depending on its state of cleanliness. This transition is shown as (1). Pages on both lists are
            still valid pages, so if a page fault occurs and one of these pages is needed, it is removed from
            the list and faulted back into the working set without any disk I/O (2). When a process exits
            its nonshared pages cannot be faulted back to it, so they go on the free list (3). These pages are
            no longer associated with any process.
            Other transitions are caused by other daemon threads. Every 4 seconds the swapper thread runs
            and looks for processes all of whose threads have been idle for a certain number of seconds. If
            it finds any such processes, their kernel stacks are unpinned and their pages are moved to the
            standby or modified lists, also shown as (1).
            Two other daemon threads, the mapped page writer and the modified page writer, wake up
            periodically to see if there are enough clean pages. If there are not, they take pages from the
            top of the modified list, write them back to disk, and then move them to the standby list. The
            former handles writes to mapped files and the latter handles writes to the paging files. The
            result of these writes is to transform dirty pages into clean pages.

            The reason for having two threads is that a mapped file might have to grow as a result of the
            write, and growing it requires access to on-disk data structures to allocate a free disk block, if
            there is no room in memory to bring them in when a page has to be written, a deadlock could
            result. The other thread can solve the problem by writing the pages to a paging file, which never
            grows. Nobody ever said Windows 2000 was simple.
            The other transitions in Figure 12.13 are as follows. If a process unmaps a page, the page is
            no longer associated with a process and can go on the free list (5), except for the case that it is
            shared. When a page fault requires a page frame to hold the page about to be read in, the page
            frame is taken from the free list (6), if possible. It does not matter that the page may still contain
            confidential information because it is about to be overwritten in its entirety. The situation is
            different when a stack grows.
            In that case, an empty page frame is needed and the security rules require the page to contain
            all zeros. For this reason, another kernel daemon thread, the zero page thread, runs at the lowest
            priority, erasing pages  that  are  on  the  free  list  and  putting  them  on  the  zeroed  page  list  (7).




                                             LOVELY PROFESSIONAL UNIVERSITY                                   367
   369   370   371   372   373   374   375   376   377   378   379