16. Segmentation Flashcards

1
Q

What is the issue with base and bounds that segmentation tries to solve? How does it solve it?

A

Internal fragmentation because of unused space between stack and heap. Instead of allocation a contigious chunk of memory, a segment per logical segment of program is allocated (for code, heap, stack).

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

What registers does segmentation use?

A

It uses three pairs or base/bounds register (1 pair per segment)

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

How does hardware knows an offset into segment and to which segment the reference is made in explicit approach?

A

Use top bits of virtual address to distinguish between segments. The rest of bits in address is offset.

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

What are downsides of explicit approach?

A
  • 1 bit goes unused as there are 4 variations and only 3 segments (some systems put code in the same segment as heap to solve this)
  • Each segment is limited to a maximum size
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does hardware knows an offset into segment and to which segment the reference is made in implicit approach?

A

Hardware determines the segment by noticing how address was formed (i.e from program counter, based off of the stack, else is heap)

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

What additional hardware information is required to have with stack and why?

A

Because stack grows upwards (to lower addresses), an extra bit that indicates whether it grows upwards or downwards is required.

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

How is physical translation performed for a stack?

A

Instead of just adding the offset to base, the maximum size segment is subtracted from offset, and then this value is added to base

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

What kind of efficiency (among others) exist in segmentation that required new support from hardware in form of protection bits? What is protection bit?

A

Code sharing. Protection bits indicate whether or not program can read, write or execute segment

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

How is segmentation where address space is chopped up into relatively large, coarse chunks is called? What is the opposite?

A

Coarse-grained. Opposite is fine-grained where address space consists of a large number of smaller segments.

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

What does fine-grained segmentation approach requires?

A

Some kind of segmentation table to manage large number of segments

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

Segmentation solves internal fragmentation, but brings an issue of …

A

External fragmentation due to variable sized chunks of memory.

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

What technique can be used to fix external fragmentation?

A

Compacting physical memory (rearranging segments)

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

What OS should do with virtual memory variables on context switch?

A

All base/bounds register must be saved/restored

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

What OS should do when the memory is requested in heap, but heap is too small?

A

Grow the heap size (e.g with sbrk() or brk() system call) and update segment size register (bounds)

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