Memory Management Flashcards

1
Q

What are the two types of variables?

A

Locally Declared

  • part of a stored program
  • loaded into memory by the OS

Dynamically allocated

  • process asks the OS for some memory (privileged)
  • gets a pointer in its own address space
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are logical/virtual and physical addressing?

A

Logical/Virtual

  • generated by the CPU
  • what the program “sees” and uses
  • bound to physical addresses
  • in the virtual address space

Physical

  • the actual location of data
  • generated by the MMU (memory management unit)
  • passed to memory hardware
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Difference between compile time and load time binding?

A

compile time

  • compiled code contains physical memory addresses
  • inflexible - have to recompile to move proess

load time

  • compiler generates re-locatable code (relative addresses)
  • process must occupy contiguous memory to work

neither used by modern general purpose OSs

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

What is a run-time binding?

A
  • run time binding yields different logical and physical addresses
  • logical addresses are dynamically mapped to physical ones
  • flexible, can occupy non-contiguous memory and can be moved during execution
  • MMU carries out the mapping
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

difference between static and dynamic linking of programs?

A
  • in static linking the linker combines object code of application modules with object code containing system library routines
  • this wastes space as each program has a copy of the system library
  • if a library routine is changed the program must be re-linked
  • in dynamic linking the linker generates an executable with a stub (code specifying how to locate) for each library routine
  • the stub is overwritten with the address of the routine on the first execution, subsequent execution incurs no overhead
  • all executing programs use the same copy, this requires support from the OS
  • if a routine is changed the new version is used next time the program is run
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

4 types of memory allocation?

A

Single Contiguous
- All the computer’s memory is available to the single application.

Partitioned

  • memory is partitioned into contiguous blocks for each program
  • programs have base and limit registers to protect memory

Paging

  • dedicated MMU maps pages to frames
  • managed in real time
  • translates logical to physical

Segmentation
- processes are assigned segments

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

Describe contiguous memory allocation

A

processes are simply assigned contiguous memory on top of each other

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

Describe the function of the limit register

A

the limit register points to the limit of a program’s contiguous memory, and prevents the process from accessing memory beyond it and traps to the OS

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

what does the relocation register do?

A

acts as an offset from the logical address to the physical address

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

why use variable size regions over fixed size and how?

A
  • fixed size are too restrictive and wasteful
  • use a free list instead to search for memory hole large enough for the process and remove it from the list
  • on termination the region is returned to the free list
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

difference between mmap and malloc

A

mmap is a syscall

  • asks the os to allow us access to additional memory
  • will update the page table and protection bits

malloc is a library func

  • may call mmap if needed
  • or just give a pointer to existing memory
  • requires some bookeeping
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is a free list?

A

It operates by connecting unallocated regions of memory together in a linked list

To free a region, one would just link it to the free list. To allocate a region, one would simply remove a single region from the end of the free list and use it. If the regions are variable-sized, one may have to search for a region of large enough size, which can be expensive.

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