An improved algorithm based on the clock algorithm but also using working set information is called WSClock. Due to the ease of implementation and good performance, it is quite widely used in practice. The necessary data structure is reduced to a cyclic list of page blocks, as in the "clock" algorithm. Initially, this list is empty. When the first page is loaded, it is added to the list. As subsequent pages are loaded, they fall into the list, forming a closed ring. Each entry contains the last use time field from the basic working set algorithm, as well as an R bit (shown in the figure) and an M bit (not shown in the figure). As in the clock algorithm, for each missing page error, the page pointed to by the arrow is checked first. If the R bit is set to 1, then the page has been used during the current clock, so it is not an ideal candidate for deletion. Then the R bit is set to 0, the arrow moves to the next page, and the algorithm is repeated already for it. The state resulting from this sequence of events. Now let's see what happens if the page pointed to by the arrow has bit R = 0, as shown in Fig. If its age exceeds t and the page has not been modified, it does not belong to the working set and its exact copy is present on disk. Then a new page is simply placed in the page block. On the other hand, if the page has been changed, its block cannot be immediately claimed, since there is no exact copy of it on disk. To avoid switching the process, the disk write is scheduled, and the arrow moves further and the algorithm continues its work on the next page. In the end, you should get an old, unchanged page, which you can use right away. In principle, a disk I/O operation for all pages can be scheduled in one clockwise rotation. To reduce the flow of data exchange with the disk, a limit can be set, which allows a maximum of n pages to be dumped to the disk. After this limit is reached, no more writes to the disk are scheduled. And what to do if the arrow goes full circle and returns to the initial position? Then you should consider two options:
-
-