13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

58 Space Management Chapter 3Processes that are blocked for a long time in wait lists should be removed from mainstore temporarily to make room for ready processes. We say these processes have beenswapped out and later will be swapped in again. While a process is swapped out, itresides in backing store, which is usually a disk or a drum. We sometimes refer to thelocation in backing store used for swapping as swapping space. The context block of aswapped-out process should indicate where it has been placed in backing store. The contextblock itself is usually not swapped out.Swapping should follow the Cache Principle of operating systems, a principle thatwe will encounter several times in this book.Cache PrincipleThe more frequently data are accessed, the faster the access should be.A cache is a repository for data from which they can be accessed quickly. We will usethe term archive to refer to the slower storage in which the data may also be stored.Copying the data from the cache to the archive is called archiving, and copying datafrom the archive to the cache is called caching. If data are both in the cache and in anarchive, the cache holds the more accurate version. The Cache Principle says that themost frequently accessed data should be kept in the cache.In our case, main store is a cache, and backing store is its archive. Swapping aprocess out is equivalent to archiving it; swapping it back in is like caching it. The spaceoccupied by ready processes is accessed more often than that occupied by blockedprocesses. Therefore, blocked processes may be swapped out to make room for activeprocesses.Violating the Cache Principle can lead to unfortunate results. In most situationsinvolving caches, data must be cached from the archive before they can be used. If thefrequency at which data are accessed is misjudged, the data may be repeatedly cachedand archived. If this situation persists, a situation called thrashing results. When theoperating system is thrashing, moving data between two levels of storage becomes thedominant activity of the machine. Thrashing due to continual swapping was a severeproblem with early attempts at storage management.1.2 Storage hierarchiesStorage organizations often use more than two levels. Each level can be considered anarchive for the cache that sits above it. For example, Figure 3.1 shows a four-levelstorage organization. Imagine a program that is saved on a long-term magnetic tape. Itmay take about 50 seconds to read that tape onto the disk. (This operation of cachingfrom tape to disk is sometimes called ‘‘staging’’.) It may then take about 50 millisecondsto read a particular block of the disk into main store. Before any given instruction is executed,the hardware loads it into a cache for fast access.Data stored on the disk are generally stored on tape as well, except for recentlymodified data, which will eventually be archived to tape. Similarly, data in main store

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!