16. Segmentation Flashcards

1
Q

What is segmentation?

A

Dividing the address space by having a base and bounds pair per logical segment. The segments are code, stack and heap.

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

What is a sparse address space?

A

A virtual address space that contains unused areas of memory

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

What is segmentation fault?

A

Accessing an address that is out of bounds

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

How many bits do we use to address segments?

A

Two bits, because there are three segments (code, stack, heap)

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

How to calculate offset in code and heap segment?

A

(Virtual address minus previous segment address) + base address

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

How to calculate virtual address in stack segment?

A

(Offset - maximum segment size) + base address

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

What are protection bits?

A

Bits to indicate whether the program can read, write or execute the segment.

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

What is coarse-grained segmentation?

A

Address space of a process is divided into a small number of large segments

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

What is fine-grained segmentation?

A

Address space of a process is divided into a large number of small segments

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

What is a segment table?

A

A data structure used in memory management to keep track of segments in process address space. For each segment, there will be a base and bounds value

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

What is external fragmentation?

A

When there are gaps between the address spaces

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

What are some ways to fix external fragmentation?

A

Reorder and compact the existing segments

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

What are some algorithms for free-list management?

A
  1. Best-fit: Traverse the whole list and find the smallest slot that can fit it
  2. Worst-fit: Traverse the whole list and find the largest slot that can fit it
  3. First-fit: Fit it in the first slot that can fit it
  4. Last-fit: Start traversing from the last slotted position and fit it in like first-fit
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are some problems of segmentation?

A
  1. Context switch: save the registers and restore them
  2. Malloc: no solution to grow it dynamically
  3. Variable sizing: every segment has different sizes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly