Interview Q&A / Operating Systems

IntermediateQuick answer1 min readUpdated 3 Oct 2026

Given a segment table, how do you translate the logical address (1, 500)?

SHORT ANSWER

Look up segment 1, compare the offset with its limit, and add the offset to its base. If the offset is not below the limit the hardware traps. With limit 400 here, (1, 500) is invalid; (0, 500) maps to 1900.

Explain it simply

A segmented logical address is a pair (segment number, offset). The segment table has a base (where the segment starts in RAM) and a limit (its length) for each segment.

Rule: if offset < limit, physical = base + offset; otherwise trap with a segmentation fault.

SegmentBaseLimit
014001000
16300400
24300400

Example

Translate three addresses:

  1. (0, 500): limit is 1000 and 500 < 1000, so physical = 1400 + 500 = 1900.
  2. (1, 399): limit is 400 and 399 < 400, so physical = 6300 + 399 = 6699.
  3. (1, 500): limit is 400 and 500 >= 400, so this is invalid. The hardware traps to the OS, which usually kills the process.

Note that offset 400 in segment 1 is also invalid: valid offsets run from 0 to limit - 1, which is 0 to 399.

The same check catches a buffer overflow that runs past the end of a segment, which is why such a bug shows up as "segmentation fault" on Linux.

What to say in the interview

"I look up the segment's base and limit. If the offset is less than the limit, physical is base plus offset; otherwise it is a trap. So (0, 500) is 1900, and (1, 500) fails because segment 1 is only 400 long."

Common mistakes

  • Using offset <= limit. The last valid offset is limit - 1.

#segmentation#memory#worked-example

Related questions

Practise more Operating Systems questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Operating Systems quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.