Memory Management - 3 Flashcards
What is segmentation?
Dividing the address sapce of each process into several sections
What segments the compiler needs?
source text - the text to be translated.
symbol table
constants segments
stack
parse tree
compiler executable code
Most of these segments grow during execution.
What is the segment table for?
Holds information for each segment:
where it starts - base, and its size - limit.
The CPU generate a virtual address for each reference - {s_num|off}.
off > S[s_num].limit -> trap; addressing error
else, physical address = S[s_num].limit + off
Is the segmented address space virtual?
Of course.** If translating results with no actual page on **RAM,** we do **swapping.
Need the programmer be aware to which technique is being used(Paging vs Segmentation)?
Paging - No. because every type of memory is treated in the same way.
Segmentation - Yes.
How many linear address spaces are there?
(Paging vs Segmentation)
Linear address - virtual addresses which are calculated using segment translation.
Paging - just one. all in one segment
Segmentation - many
That is, with paging specific data can be placed anywhere within the virtual space. In segmentation it has a desired range.
Can the total address space exceed the size of physical memory(Paging vs Segmentation)?
Paging - Yes, Segmentation - Yes. that’s the whole point with virtual addresses. Though in Segmentation, if one segment don’t have space in RAM we’re in problem..
Can procedures and data be distinguished and saparetely protected(Paging vs Segmentation)?
Paging - No. Because each chunk of memory is mixing procedures and data. so we can’t treat each in a distinguished manner.
Segmentation - Yes. because with segments we make a distinction(in terms of memory chunks) between code and data.
Can tables whose size fluctuates be accomodated easiliy(Paging vs Segmentation)?
Paging - No. Page table size if fixed.
Segmentation - Yes, each segment can dynamically grow.
Is sharing of procedures between users facillitated(Paging vs Segmentation)?
facillitated = it makes it easier.
Paging - No. procedures have no distinguished area.
Segmentation - Yes.
procedures have distinguished area.
Why was this technique invented?(Paging vs Segmentation)
Paging - to get a large linear address space without having to buy more physical memory
Segmentation - to allow programs and data to be broken up into logically independent address spaces and to aid sharing and protection.
What are the advantages/disadvantages of Segmentation?
Advantages
Growing and shrinking independently. (not of a fixed size).
Sharing between processes simple - because the division into data/procedures and such
Linking is easier - same reason as above.
Protection easier - the distinction between types of data makes it easier.
Disadvantages
Pure segmentation - might cause external fragmentation
Segments may be very large - what if they don’t fit into physical memory?
- How is the Segment Table reached?*
- How is protection defined?*
It is reached via two registers:
STBR - points to the table’s location in memory
STLR - indicates number of segments used by a program.
- if segment_number < STLR it is legal.*
- Each segment table entry contains:*
validation bit = 0 -> illegal segment
read/write/execute** **priviliges.
Note: protection bits associated with segments: code sharing occurs at segment level.
Which problem Segmentation with Paging solves?
- Too large Segments.
- External fragmentation.
How Segmentation + Paging is implemented in MULTICS?
- Each program has a segments table which itself is, a segment.*
- Each segment has a page table.*
- Each segment has segment descriptor. The descriptor-base-register points to its page table*
- Memory reference procedure:*
segment table is itself paged because it may be large.
1. CPU generates virtual address: {seg_num | d}
2. seg_num refers to STBR - discriptor base register.
3. STBR refers to the segment table entry: {segment length | page table base}
4.** d > segment length? **trap.
5.** d = {**page table offset|** **page offset}
6.** page table base + page table offset = **f
7.** f is not in memory? **page fault.
8.** f + page offset - **desired location
segment number -> segment descriptor -> check if page table is in memory(if not - segmentation fault) -> page table entry examined - page base(if not in memory - segmentation fault) -> offset is added to page base -> perform read/store etc.