The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+1 vote
asked in Operating System by (17 points) | 68 views

1 Answer

0 votes

Well, although the both seem to be dividing memory into parts, but their lies a difference in the way (and in situations) they are useful.


Overlaying is a programming method that allows programs to be larger than the computer's main memory. This larger memory is achieved by programmer manually specifying what should be present in memory at a particular instance of time. Thus a programmer can write 10 overlays of 512KB and choose that at a time only two overlays be present.

A real word example can be, consider a space shuttle program. It may have a launcher module code, mid-air module code.. etc. These can be thought of as overlays - LauncherOverlay, MidAirOverlay etc. Since memory is critical in space shuttle (and so is the processing speed), programmer would specify LauncherOverlay to be in memory. Once launch has taken place, we would no longer need LauncherOverlay, so now programmer can specify MidAirOverlay to be in memory. 

Because only one (or few) of them is in memory at a time, there is no need to MMU (Memory Management Unit which translates virtual address to physical address). So, even without using Virtual address (space), programmer is able to program using larger memory. This results in speed too.


Well, they too are used to divide the code in to various parts called segments, but they are usually used for keeping the memory address spaces separate. Like StackSegment, CodeSegment, DataSegment etc. But why would we need address spaces to be different. This is because a in linear address space, if we divide the memory into parts mentioned above, then we would have to specify a maximum space which a certain part can take. 

Example can be to consider a memory from address 0 to 99.  if a StackSegment is from address 0 to 20, CodeSegment from 21 to 45 etc, then these cannot grow beyond address mentioned. But what if at runtime, a process needs more memory ? it is not always possible to know this in advance. 

So we want address spaces to be linearly independent i.e. all segments would start from address 0 whether it is StackSegment or CodeSegment or any other. These segments would then be loaded to separate spaces. So these can grow (and shrink) independently. 

Also segments are used to enable sharing portions of memory - a key distinction from overlays.

answered by Loyal (5.3k points)

Related questions

0 votes
1 answer
+1 vote
1 answer
0 votes
1 answer
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
47,881 questions
52,233 answers
67,653 users