Memory Management Flashcards

1
Q

Why is memory management relevant to to Operating System?

A

OS responsible for loading programs into memory, physical addresses are HW dependent.

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

What is the purpose of memory protection?

A

Processes share physical memory, need to restrict access to prevent errors and improper access.

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

What types of variables are there?

A

Locally declared (part of stored program), loaded into memory by OS

Dynamically allocated, Malloc - process asks for some memory.

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

What is a logical address?

A

Memory address generated by the CPU and is in the virtual address space.

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

what is a physical address?

A

Memory address generated by the Memory Management Unit (MMU)

Passed to memory hardware and is in the physical address space.

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

What is address binding?

A

Mapping symbolic address to physical addresses.

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

What are the attributes of compiled code?

A

Contains Physical memory addresses

Inflexible, have to re-compile to move process.

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

What happens at load time?

A

Compiler generates relative addresses (re-locatable code)

Process must occupy contiguous region of memory.

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

What do load time and compile time both result in?

A

Identical logical and physical memory addresses. (not used)

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

What is run-time binding?

A

Yields different logical and physical addresses.

Logical addresses dynamically mapped to physical addresses

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

What are the advantages of run-time binding?

A

It’s felxible, process can occupy non-contigous regions of physical memory and can be moved in memory during execution.

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

What are the disadvantages of run-time binding?

A

Runtime overheads means HW support required, MMU carries out the mapping.

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

What is static linking?

A

Linker combines object code of application modules with object code containing system library routines.

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

What are the disadvantages of static linking?

A

Wastes space as each program has a copy of system library

If a library routine is changed program must be re-linked.

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

What is dynamic linking?

A

Linker generates executable with stub (code specifying how to locate routine) for each library routine

Stub overwritten with address of routine on first execution. (subsequent execution incurs no overhead)

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

What are the advantages of dynamic linking?

A

All executing programs use same copy.

If library routine is changed, new version will be used next time program is run.

17
Q

What types of allocation are there?

A
  • Single contiguous
  • Partitioned
  • Paging
  • Segmentation
18
Q

What is single contiguous memory allocation?

A

Everything goes to one process

19
Q

What is partitioned memory allocation

A

Contiguous partition for each program.

HW support for memory protection.

20
Q

How does segmentation find a memory address

A

Segment address + offset address

21
Q

How is memory protected?

A

Dynamic binding and checking, relocatable regions and resizable contiguous memory space.

22
Q

How does the OS allow variable size regions of memory?

A

OS holds a free list.

Search for memory hole large enough for new process assign the memory space and remove the address from the free list.

On termination, region is returned to the free list.

23
Q

How does virtual memory work?

A

Logical address space of process, each logical address is bound to a physical address dynamically.

Split into 4kb blocks known as pages.

24
Q

How is a linux process’s virtual memory structured?

A

Split into segments:

Code segment
Data segment
BSS (block started by symbol)
Stack Segment

25
Q

What’s the difference between Mmap and malloc

A

MMAP: Sys call, asks OS for additional memory and updates page table and protection bits

Malloc is a lib functions, may call mmap or gives a pointer to existing memory. Also does book keeping.

26
Q

What does the Malloc Data Structure consist of and enable?

A

Records block size and allocated/free status. Enables coalescing of adjacent free blocks.

Coalascing: Join together two free blocks of memory.