Segment table problem


#1

Consider the following segment table:
image
Find the physical address for the logical addresses (2, 40) and (1, 500).


#2

(2,40)
Here 2 is segment number and 40 is the offset.
Check if offset < limt(or length),
40<130 (valid)

Go to segment number 2 in the table and see what’s the base address. It’s 40.
Now add the offset with this base address= 40+40 = 80
This is the physical address.

In 2nd case (1,500)
segment number is 1, Offset = 500.

Check if offset<limit
500<70 (invalid)

Hence, it is not valid. So it would end up in segmentation fault.


#3

here first we add base address and offset then check limit this is the way of solving?
or first check (compare) length with offset ?


#5

I also get confused with same doubt
thanks @Ruturaj for clarification


#7

I think Length here is the size of the segment.
Example: Base = 5400; Length = 70
So it will be a segment with start address 5400 and end address as 5469

@Ruturaj in segmentation don’t we first compare the offset with the limit or length. If the (offset < limit) then we add offset to the base address.


#8

I have updated my answer. Here the length field actually means limit.


#9

first we compare offset with limit, if true then we add offset and base , right ?


#10

Yes @Mohit_Bawankar @Isha_Kashyap. We first compare and then add