The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+1 vote
53 views
asked in Operating System by (17 points) | 53 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.

Overlays:

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.

Segments:

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.4k points)

Related questions

0 votes
1 answer
1
0 votes
1 answer
3
asked Sep 12, 2015 in Operating System by radha gogia Loyal (7.7k points) | 1.4k views
+1 vote
1 answer
4
+1 vote
1 answer
6


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

42,568 questions
48,554 answers
155,368 comments
63,556 users