Memory Management - 3 Flashcards

1
Q

What is segmentation?

A

Dividing the address sapce of each process into several sections

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What segments the compiler needs?

A

source text - the text to be translated.

symbol table

constants segments

stack

parse tree

compiler executable code

Most of these segments grow during execution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the segment table for?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Is the segmented address space virtual?

A

Of course.** If translating results with no actual page on **RAM,** we do **swapping.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Need the programmer be aware to which technique is being used(Paging vs Segmentation)?

A

Paging - No. because every type of memory is treated in the same way.

Segmentation - Yes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How many linear address spaces are there?

(Paging vs Segmentation)

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Can the total address space exceed the size of physical memory(Paging vs Segmentation)?

A

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..

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Can procedures and data be distinguished and saparetely protected(Paging vs Segmentation)?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Can tables whose size fluctuates be accomodated easiliy(Paging vs Segmentation)?

A

Paging - No. Page table size if fixed.

Segmentation - Yes, each segment can dynamically grow.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Is sharing of procedures between users facillitated(Paging vs Segmentation)?

facillitated = it makes it easier.

A

Paging - No. procedures have no distinguished area.

Segmentation - Yes.

procedures have distinguished area.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why was this technique invented?(Paging vs Segmentation)

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the advantages/disadvantages of Segmentation?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  • How is the Segment Table reached?*
  • How is protection defined?*
A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which problem Segmentation with Paging solves?

A
  1. Too large Segments.
  2. External fragmentation.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How Segmentation + Paging is implemented in MULTICS?

A
  • 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
  • What are the Unix memory management sys calls?*
  • brk(addr), mmap(addr, len, prot,flags, fd, offset), unmap(addr, len)?*
A

POSIX does not specify how malloc is implemented.

brk(addr)

change data segment size. addr specifies the first address following new size.

mmap(addr, len, prot,flags, fd, offset)

map(open, if needed) file fd starting from offset in length len to virtual address addr(0 if OS is to set address)

unmap(addr, len)

unmap a file, or a portion of it(using len).

17
Q

What is Unix Page Daemon serve for?

A

Unix Page Daemon -

  • Responsible to free page frames.
  • Awakened periodically to inspect the state of memory - if less than 1/4’th of page frames are free, then it frees page frames.
  • This strategy works better than evicting pages when needed; writing the modified to disk in hurry.
  • It helps view all available memory as page-pool.
  • It uses a global clock algorithm - two-handed clock.
18
Q

What is the Two-Handed Clock algorithm?

A

Two-Handed Clock algorithm:

  • First hand - clears the reference bit.
  • Seconds hand - frees pages.
  • Each hand works against the other
    • If the reference bit is set - the distance between the hands increases(angle)
    • If two hands come together the page is being freed.
  • If there is thrashing
    • the swapper process removes processes to disk
      • removes processes idle for 20 sec or more
      • if none - swap out the oldest.
  • who get swapped back is a function of:
    • Time out of memory
    • size
19
Q

How Linux manages memory for processes?

A

Each process has:

  • 3GB virutal memory
    • Composed of areas with same:
      • Protection
      • Paging properties
        • pageable or not
        • direction of growth
  • 1GB of memory for kernel and pages tables
  • A linked list of areas, sorted by virtual address:
    • text, data, memory-mapped-files,…
20
Q

How does Linux manage memory?

A
  • Kernel is never swapped
  • The buddy algortihm is used. In addtion:
    • Linked lists of same-size free blocks are maintained.
    • To reduce internal fragmentation:
      • A second memory allocation scheme manages smaller units inside buddy-blocks.
  • Demand paging(no pre-paging)
  • Dynamic backing store management
21
Q

What is Linux page replacement algorithm?

A

Linux page replacement algorithm:

  • Varing of clock algorithm
  • Order of inspection of the page-freeing daemon is:
    • By size of process - large to small
    • In virtual address order
  • Freed pages are categorized:
    • clean; dirty; unbackedup
  • Another daemon writes up dirty page periodically.