Swapping

COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION

Referring back to Figure 8.11, we have discussed three types of queues: the long-
term queue of requests for new processes, the short-term queue of processes ready
to use the processor, and the various I/O queues of processes that are not ready to
use the processor. Recall that the reason for this elaborate machinery is that I/O
activities are much slower than computation and therefore the processor in a uni-
programming system is idle most of the time.
But the arrangement in Figure 8.11 does not entirely solve the problem. It is
true that, in this case, memory holds multiple processes and that the processor can
move to another process when one process is waiting. But the processor is so much
faster than I/O that it will be common for all the processes in memory to be waiting
on I/O. Thus, even with multiprogramming, a processor could be idle most of the
time.
What to do? Main memory could be expanded, and so be able to accommo-
date more processes. But there are two flaws in this approach. First, main memory
is expensive, even today. Second, the appetite of programs for memory has grown
as fast as the cost of memory has dropped. So larger memory results in larger proc-
esses, not more processes.
 
 
Another solution is swapping, depicted in Figure 8.12. We have a long-term
queue of process requests, typically stored on disk. These are brought in, one at a
time, as space becomes available. As processes are completed, they are moved out
of main memory. Now the situation will arise that none of the processes in memory
are in the ready state (e.g., all are waiting on an I/O operation). Rather than remain
idle, the processor swaps one of these processes back out to disk into an intermediate
queue.
This is a queue of existing processes that have been temporarily kicked out
of memory. The OS then brings in another process from the intermediate queue, or
it honors a new process request from the long-term queue. Execution then contin-
ues with the newly arrived process.
Swapping, however, is an I/O operation, and therefore there is the potential
for making the problem worse, not better. But because disk I/O is generally the
fastest I/O on a system (e.g., compared with tape or printer I/O), swapping will usu-
ally enhance performance. A more sophisticated scheme, involving virtual memory,
improves performance over simple swapping. This will be discussed shortly. But
first, we must prepare the ground by explaining partitioning and paging.
 
 
原文地址:https://www.cnblogs.com/rsapaper/p/6216601.html