chapter 16 - segmentation Flashcards

1
Q

basic idea behind segmentation

A

Divide address space into logical segments (Code, Heap, Stack), each with its own base and bounds

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

What problem does segmentation solve?

A

It avoids filling physical memory with unused virtual address space

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

How does memory access work with segmentation?

A

Hardware checks segment

Uses base + offset to find physical address

Checks if access is within bounds

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

How does the hardware determine which segment a virtual address refers to?

A

By using the top few bits of the virtual address (top 2)

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

What do the remaining lower bits of a virtual address specify?

A

The offset within the segment

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

which direction does the stack grow

A

downward - negative

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

How does the hardware support negative growth segments like the stack?

A

Segment registers store the growth direction and adjust address translation accordingly

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

Why share code segments between processes?

A

To save memory while maintaining process isolation

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

How is memory protection enforced in segmentation?

A

Using protection bits that define read, write, and execute permissions per segment

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

What happens if an access violates protection bits?

A

The CPU traps to the OS, and the offending process is handled

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

What is coarse-grained segmentation?

A

Few large segments like Code, Heap, Stack

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

What is fine-grained segmentation?

A

Many small segments - often thousands, each representing small pieces of code or data

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

What must the OS do during a context switch?

A

Save and restore segment registers (base, size, growth direction, protection)

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

How does the OS handle heap growth during execution?

A
  • A system call to the OS for more memory
  • OS increases the heap segment size if possible
  • OS updates the segment size register
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is external fragmentation?

A

When enough free memory exists overall, but not in a large enough contiguous block to satisfy an allocation request

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

How can external fragmentation be reduced?

A
  • Compaction: Rearranging memory to create large contiguous free blocks
  • Free-list algorithms: Best-fit, Worst-fit, First-fit, Buddy system