The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+10 votes
1.4k views

A linker reads four modules whose lengths are $200, 800, 600$ and $500$ words, respectively. If they are loaded in that order, what are the relocation constants?

  1. $0, 200, 500, 600$
  2. $0, 200, 1000, 1600$
  3. $200, 500, 600, 800$
  4. $200, 700, 1300, 2100$
asked in Compiler Design by Veteran (59.7k points)
edited by | 1.4k views

1 Answer

+20 votes
Best answer

answer - B

first module loaded starting at address $0$. Size is $200$. hence it will occup first $200$ address last address being $199$. Second module will be present from $200$ and so on.

answered by Loyal (8.8k points)
edited by
0
first module loaded starting at address 0. Size is 200. hence it will occup first 200 address last address being 199. Second module will be present from 200 and so on
0
Can you explain it more clearly ??
0

Module Number Base Limit
1 0 200
2 200 800
3 1000 600
4 1600 500

 

So, if my program wants to access byte 'x' in module 3, so address that needs to be accessed will be computed as Base(1000)+(x-1)=999+x Byte number.

And, if suppose I try to access Byte 600 in module 3,

$600 \not \lt600(limit)$, a trap to the O.S. will be generated.

So, answer is (B)

 

0

@Ayush+Upadhyaya

Is it always the case that ..linker will place module 2 after module 1 ..then module 3 after module 2

(Here I mean module -> Object code(.o) )

What if it place module 2 before 1...?? m confused now :(

0

If they are loaded in that order

@jatin khachane 1  it is mentioned. Otherwise linker will ask OS for free slot in memory and suppose OS provides address x then in base register of that module x will be stored and relative addresses will be converted to absolute accordingly.

0

What if it place module 2 before 1...??

Yes it is possible. But during program execution MMU will take care of it using page tables. 

Answer:

Related questions



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

44,383 questions
49,872 answers
164,901 comments
65,881 users