Docsity

Overlays-Operating Systems-Lecture Notes, Study notes of Operating Systems

Toggle sidebar
bg1
156
Operating Systems [CS-604] Lecture No.31
Operating Systems
Lecture No. 31
Reading Material
Chapter 9 of the textbook
Lecture 31 on Virtual TV
Summary
Overlays
Swapping
Contiguous memory allocation
MFT
Overlays
To enable a process to be larger than the amount of memory allocated to it, we can use
overlays. The idea of overlays is to keep in memory only those instructions and data that
are needed at any given time. When other instructions are needed, they are loaded into
space occupied previously by instructions that are no longer needed. We illustrate the
concept of overlays with the example of a two-pass compiler. Here are the various
specifications:
2-Pass assembler/compiler
Available main memory: 150k
Code size: 200k
¾ Pass 1 ……………….. 70k
¾ Pass 2 ……………….. 80k
¾ Common routines …... 30k
¾ Symbol table ………… 20k
Common routines, symbol table, overlay driver, and Pass 1 code are loaded into the main
memory for the program execution to start. When Pass 1 has finished its work, Pass 2
code is loaded on top of the Pass 1 code (because this code is not needed anymore). This
way, we can execute a 200K process in a 150K memory. The diagram below shows this
pictorially.
The problems with overlays are that a) you may not be able to partition all problems
into overlays, and b) programmer is responsible of writing the overlays driver.
docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Overlays-Operating Systems-Lecture Notes and more Study notes Operating Systems in PDF only on Docsity!

Operating Systems [CS-604] Lecture No.

Operating Systems

Lecture No. 31

Reading Material

 Chapter 9 of the textbook  Lecture 31 on Virtual TV

Summary

 Overlays  Swapping  Contiguous memory allocation  MFT

Overlays

To enable a process to be larger than the amount of memory allocated to it, we can use overlays. The idea of overlays is to keep in memory only those instructions and data that are needed at any given time. When other instructions are needed, they are loaded into space occupied previously by instructions that are no longer needed. We illustrate the concept of overlays with the example of a two-pass compiler. Here are the various specifications:  2-Pass assembler/compiler  Available main memory: 150k  Code size: 200k  Pass 1 ……………….. 70k  Pass 2 ……………….. 80k  Common routines …... 30k  Symbol table ………… 20k Common routines, symbol table, overlay driver, and Pass 1 code are loaded into the main memory for the program execution to start. When Pass 1 has finished its work, Pass 2 code is loaded on top of the Pass 1 code (because this code is not needed anymore). This way, we can execute a 200K process in a 150K memory. The diagram below shows this pictorially. The problems with overlays are that a) you may not be able to partition all problems into overlays, and b) programmer is responsible of writing the overlays driver.

Overlays Example

Swapping

A process needs to be in the memory to be executed. A process, however, can be swapped temporarily out of memory to a backing store , and then brought back into memory for continued execution. Backing store is a fast disk large enough to accommodate copies of all memory images for all users; it must provide direct access to these memory images. The system maintains a ready queue of all processes whose memory images are on the backing store or in memory and are ready to run. For example, assume a multiprogramming environment with a round robin CPU scheduling algorithm. When a quantum expires, the memory manager will start to swap out the process that just finished, and to swap in another process to the memory space that has been freed. A variant of this swapping policy can be used for priority-based scheduling algorithms. If a higher-priority process arrives and wants service, the memory manger can swap out the lower-priority process so that it can load and execute the higher- -priority process. When the higher--priority process finishes, the lower--priority process can be swapped back in and continued. This technique is called roll out, roll in. The major part of swap time is transfer time; the total transfer time is directly proportional to the amount of memory swapped. Swapping is constrained by factors like quantum for RR scheduler and pending I/O for swapped out process. Assume that I/O operation was queued because the device was busy. Then if we were to swap out P1, and swap in process P2, the I/O operation might attempt to access memory that now belongs to P2.The solution to this problem are never to swap out processes with pending I/O or to execute I/O in kernel space

Contiguous Allocation

Multiprogramming with Fixed Tasks (MFT)

In this technique, memory is divided into several fixed-size partitions. Each partition may contain exactly one process. Thus the degree of multiprogramming is bound by the number of partitions. In this multiple partition method, when a partition is free, a process is selected from the input queue and is loaded in the free partition. When the process terminates, the partition becomes available for another process.

 This was used by IBM for system 360 OS/MFT (multiprogramming with a fixed number of tasks).  Can have a single input queue instead of one for each partition.  So that if there are no big jobs can use big partition for little jobs.  Can think of the input queue(s) as the ready list(s) with a scheduling policy of FCFS in each partition.  The partition boundaries are not movable and are set at boot time (must reboot to move a job).  MFT can have large internal fragmentation , i.e., wasted space inside a region  Each process has a single segment'' (we will discuss segments later)  No sharing between processes.  No dynamic address translation.  At load time mustestablish addressability''.  Must set a base register to the location at which the process was loaded (the bottom of the partition).  The base register is part of the programmer visible register set.  This is an example of address translation during load time.  Also called relocation.  Storage keys are adequate for protection (IBM method).  Alternative protection method is base/limit registers.  An advantage of base/limit is that it is easier to move a job.  But MFT didn't move jobs so this disadvantage of storage keys is moot.

Multiprogramming with Fixed Tasks (MFT) with a queue per partition

MFT with multiple queues involves load-time address binding. In this technique, there is a potential for wasted memory space i.e. an empty partition but no process in the associated queue. However in MFT with single queue there is a single queue for each partition. The queue is searched for a process when a partition becomes empty. First-fit , best-fit , worst-fit space allocation algorithms can be applied here. The following diagram shows MFT with single input queue.

Multiprogramming with Fixed Tasks (MFT) with one input queue

OS

Partition 1

Partition 2

Partition 3

Partition 4

OS

Partition 1

Partition 2

Partition 3

Partition 4 (^) 100 K

300 K

200 K

150 K

Input

Queues

OS

Partition 1

Partition 2

Partition 3

Partition 4

OS

Partition 1

Partition 2

Partition 3

Partition 4 100 K

300 K

200 K

150 K

Input Queue