📝 Basic method of Segmentation in Operating System (9 MCQs)
Dividing a Process into Logical Memory Segments
Segmentation is a memory-management technique that divides a process address space into variable-sized logical units called segments. These units represent meaningful program components such as code, data, stack, and procedures. Unlike paging, which divides memory into equal-sized blocks, segmentation follows logical program structure. It allows the operating system to manage protection, sharing, and allocation according to the requirements of individual program components.
Why Logical Program Organization Influences Memory Design
A program commonly contains components with different sizes, access permissions, and sharing requirements. Treating all memory as one undifferentiated region makes selective protection and sharing less convenient. Segmentation addresses this problem by assigning separate logical identifiers to program components. However, variable-sized segments require suitable free-space management and can create external fragmentation when segments are repeatedly allocated and released.
Segment Numbers, Offsets and Table-Based Translation
A logical address in segmentation contains a segment number and an offset within that segment. The segment number selects an entry in the process's segment table. That entry provides the segment's physical base address and length limit. Hardware verifies that the offset falls within the permitted limit, then adds the offset to the base to generate the physical address.
Translating an Address Within a Data Segment
Suppose segment 2 begins at physical address 40000 and has a length of 1200 bytes. A logical reference containing segment number 2 and offset 350 is valid and maps to physical address 40350. An offset of 1300 exceeds the segment limit and causes a protection exception. Each segment therefore has an independently defined memory boundary.
Protection, Sharing and Variable-Size Allocation
Segmentation supports different permissions for code, data, and stack components, while selected segments can be shared between processes under appropriate protection conditions. Its variable-sized regions reflect program structure, but allocation becomes more complex than fixed-size paging. External fragmentation can prevent placement of a large segment even when total available memory appears sufficient, making compaction necessary in some systems.
Common Confusions Between Segmentation and Paging
'All segments must have the same size' is incorrect because segment lengths depend on logical program components. 'A segment number alone identifies the exact byte' is incorrect because an offset is also required. 'Segmentation automatically eliminates fragmentation' is incorrect because variable-sized physical segments can create external fragmentation despite providing logical organization.
Exam Focus: Segment Table Translation and Bounds
Given a segment number, base address, and limit, determine whether an offset is valid and calculate its physical address. Remember that the physical address equals base plus offset only after successful bounds checking. Compare segmentation and paging by block size, address format, fragmentation, protection, and the organisation of their respective translation structures.
Key Terms of Segmentation
- Segment - Variable-sized logical memory unit.
- Segment number - Selects a segment entry.
- Offset - Position within a segment.
- Segment table - Stores segment descriptions.
- Base address - Starting physical location.
- Segment limit - Maximum permitted segment range.
📝 All Basic method of Segmentation in Operating System MCQs
Q1. A program generates a logical address 0x0150. The relocation register (base) is set to 0x2000. What physical address will the MMU produce?
📖 Explanation: The MMU adds the base value to the logical address, so 0x2000 + 0x0150 = 0x2150. Option A matches this calculation, making it correct. Option B omits the offset, option C uses the logical address unchanged, and option D adds an incorrect large offset. Understanding this addition shows how dynamic relocation maps virtual addresses to real memory, which is essential for running programs without compile‑time address fixes.
Q2. What is the primary function of a relocation register in dynamic address translation?
📖 Explanation: The relocation register contains the base address that the MMU adds to each logical address, enabling the program to run at different locations in memory. Option B describes this role accurately. Option A confuses it with address‑space size, option C describes a page table function, and option D suggests caching, which is unrelated. Recognizing the register’s purpose clarifies how address translation works at run time.
Q3. Process P1 has base register 0x3000 and generates logical address 0x0100. Process P2 has base register 0x4000 and generates logical address 0x0100. Which statement is true about the resulting physical addresses?
📖 Explanation: Physical address = base + logical offset. For P1: 0x3000 + 0x0100 = 0x3100; for P2: 0x4000 + 0x0100 = 0x4100. Hence P1’s address (0x3100) is lower than P2’s (0x4100), making option C correct. Option A would be true only if bases were identical, option B reverses the order, and option D is irrelevant because the calculation does not need page size. This demonstrates how separate base registers keep processes isolated in memory.
Q4. Why does the execution‑time address‑binding scheme allow a program’s logical address space to differ from the physical address space?
📖 Explanation: Dynamic binding uses a relocation register that the MMU adds to each logical address at run time, so the same logical address can map to different physical locations. Option B captures this mechanism. Option A describes static binding, option C refers to protection rather than address mapping, and option D is not a rule; logical spaces can be larger or smaller than physical memory. Recognizing this flexibility explains why modern OSes can load programs anywhere in RAM.
Q5. If a system has 64 KB of physical memory and supports programs with a maximum logical address of 32 KB, what is the minimum number of bits required for the relocation register?
📖 Explanation: The base can range from 0 to (64 KB − 32 KB) = 32 KB, which is 2^15 = 32768 possible values, requiring 15 bits to represent. Option B provides this count. Option A (8 bits) only covers 256 values, option C (16 bits) is more than needed, and option D (6 bits) covers 64 values. Knowing the range of the base register helps designers size the hardware correctly for dynamic relocation.
Q6. A program’s base register is changed from 0x1000 to 0x1800 while it is running. Which effect does this have on the mapping of its existing logical addresses?
📖 Explanation: Logical addresses remain the same; the MMU simply adds the new base for subsequent translations, leaving earlier physical addresses unchanged. Thus option C is correct. Option A would only be true if the system required re‑translation, option B incorrectly suggests retroactive shifting, and option D is unnecessary because the base can be updated on the fly. This illustrates that dynamic relocation permits moving a process without altering its code.
Q7. What is a key advantage of dynamic relocation using a relocation register compared to static relocation performed at load time?
📖 Explanation: Dynamic relocation lets the operating system change the base register while the program runs, so the process can be shifted to a different memory region without recompiling or patching addresses. Option D describes this benefit. Option A is false because the MMU is still required, option B misstates address‑space size, and option C is impossible because each process occupies distinct physical locations. This advantage is critical for multitasking and memory‑sharing.
Q8. Suppose the MMU adds the base register value to a 16‑bit logical address. If the base register holds 0xF000 and a program generates logical address 0x2000, what happens during address translation?
📖 Explanation: Adding 0xF000 and 0x2000 yields 0x11000, which needs 17 bits and exceeds the 16‑bit physical address limit (0xFFFF). The MMU therefore raises a protection fault or trap. Option B reflects this behavior. Option A would only occur with modulo arithmetic, which MMUs do not use for address translation. Option C ignores the relocation mechanism, and option D assumes a larger physical address space that is not given. Understanding this overflow helps prevent illegal memory accesses.
Q9. How does the set of all logical addresses generated by a program relate to the set of physical addresses produced by the MMU?
📖 Explanation: Every logical address is translated to a physical address, so the collection of physical addresses includes all those translations, making the logical set a subset of the physical set. Option B states this correctly. Option A would require one‑to‑one identity mapping, option C reverses the relationship, and option D ignores the systematic mapping performed by the MMU. Recognizing this subset relationship clarifies how address translation preserves program semantics while fitting into actual memory.