0% found this document useful (0 votes)
16 views7 pages

Swapping

chakram

Uploaded by

ksai.mb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views7 pages

Swapping

chakram

Uploaded by

ksai.mb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Swapping

1) Executing a process ( 1 . it has to be kept in main memory


for execution

2. it can be swapped out temporarily out of


memory to a backing store
and then swapped in to a main
memory for continuing its execution
2) Diagram

3) What is possible with Swapping? ( PA of processes > PA of


processes)
Total physical address space
of all the processes may
exceed the real

1
physical memory of the
system , thus increasing the
degree of multi programming

8.2.1 Standard Swapping

1) What it involves? ( moving of processes between


main memory and backing store)
2) Backing store? (
1. it is fast disk
2. large enough to accommodate
copies of all memory images for
all users
3. it should provide direct access to
these memory images

3) What the system maintains? (1. Ready queue consisting all


processes whose memory
images are on the backing store
or in memory and ready to
run)
4) Who executes a process and how? ( CPU scheduler with help of
dispatcher by calling and
checking and
swapping)
1. it calls dispatcher
2. Dispatcher checks to see
whether the next process in the
queue is in memory,
3. If it is not and if there is no free
memory region, it swaps out a

2
process currently in memory and
swaps in the desired process
4.it reloads the registers and
transfer the control to the selected
process.

5) Context switching time and example? ( is very high for such


swapping)

Size of user process = 100 MB


Speed of backing store = 50MB per sec
Time taken to transfer a process from main memory to
secondary store or vice versa ,100 MB/50 MB per second
= 2 seconds
Total swap time = 4000 msec

6) Relationship between total transfer time and


amount of memory to be swapped (directly
proportional)

The total transfer time is directly proportional to the


amount of memory swapped.

7)Example

Assume that main memory size = 4GB


Resident OS takes 1 GB
Remaining space = 3 GB

So the maximum size of the process that can reside in


main memory is of 3GB, but in most cases a process size
will be in MB only say 100MB whose swapping time is 2

3
sec ,compared to swapping time of 3GB process which is
60 seconds

8) Reducing swapping time? (1.Is using rather than


might be using
2. swap out only what is
actually used

Clearly, it would be useful to know exactly how much


memory a user process is using, not simply how much it
might be using. Then we would need to swap only what
is actually used, reducing swap time.

9) How this method can be made effective?


(informing,dynamic)
( if user keep the system
informed about
any changes in memory
requirements
For this method to be effective, the user must keep the
system informed of any changes in memory
requirements. Thus, a process with dynamic memory
requirements will need to issue system calls (request
memory() and release memory()) to inform the
operating system of its changing memory needs.

10) When we can swap a process? (1.a process is idle


2.waiting for
I/O operation
If we want to swap a process, we must be sure that it is
completely idle. Of particular concern is any pending I/O.
A process may be waiting for an I/O operation

4
11) Problems that may occur while swapping such
a process
When I/O asynchronously accessing
the user memory (example p1 and p2)

if the I/O is asynchronously accessing the user memory


for I/O buffers, then the process cannot be swapped.
Assume that the I/O operation is queued because the
device is busy. If we were to swap out process P1 and
swap in process P2, the I/O operation might then attempt
to use memory that now belongs to process P2.

12) Solution ( 1. never swap a waiting process


2. execute I/O operations only in OS buffers

There are two main solutions to this problem: never swap


a process with pending I/O, or execute I/O operations only
into operating-system buffers.

13) Limitation of standard swapping? (Execution


time <
swapping time)
Standard swapping is not used in modern operating
systems. It requires too much swapping time and
provides too little execution time to be a reasonable
memory-management solution.

14) How the swapping time can be reduced (


disabling,
enabling, halting)

1. by disabling swapping

5
2. Enabling when the free
memory falls below a threshold
value
3. Halting when amount of free
memory increases
4.swapping only portions of
processes
Swapping is normally disabled but will start if the amount of free
memory (unused memory available for the operating system or
processes to use) falls below a threshold amount. Swapping is
halted when the amount of free memory increases. Another
variation involves swapping portions of processes—rather than
entire processes—to decrease swap time

8.2.2 Swapping on Mobile Systems

1) They won’t support swapping (1.they use flash


memory rather
than hard disks
2. resulting space constraint

Mobile systems typically do not support swapping in any


form. Mobile devices generally use flash memory rather
than more spacious hard disks as their persistent storage.

The resulting space constraint is one reason why mobile


operating-system designers avoid swapping.
2) Limitation with flash memory? (it can tolerate a
limited no of writes)

Other reasons include the limited number of writes that


flash memory can tolerate before it becomes unreliable
and the poor throughput between main memory and flash
memory in these devices.
6
3) Strategy adopted by apple IOS? (by asking
application ,
terminating applications

Instead of using swapping, when free memory falls below


a certain threshold, Apple’s iOS asks applications to
voluntarily relinquish allocated memory. Read-only
data (such as code) are removed from the system and
later reloaded from flash memory if necessary. Data that
have been modified (such as the stack) are never
removed. However, any applications that fail to free up
sufficient memory may be terminated by the
operating system.

3) Strategy adopted by android?( by terminating a


process
By writing application
state to flash memory
It may terminate a process if insufficient free memory is
available. However, before terminating a process, Android
writes its application state to flash memory so that it
can be quickly restarted

You might also like