Memory Manager Flashcards

1
Q

Memory Manager

A

Manages the main memory and ensures each process gets access to the memory it needs. Tasks include:
- preserves and protects space in memory occupied by OS
- checks validity of each request for memory space
- allocates free areas of memory to valid requests, and deallocates the memory when finished
- keeps track of which users and processes are using which memory
- provides syscalls and manages swap space

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

Memory Addressing/ Linear Store

A

Memory inside a system can be viewed in a linear sequence of bytes called linear store, or flat model, with memory being byte addressable starting from 0 to allowed amount of bytes.

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

Program Storing

A

A program exists on disk as a binary executable file, storing program instructions as a sequence of bytes.

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

Running A Program / Process Image

A

When a program is run:
- binary image/the sequence of bytes is loaded into main memory
- extra memory is reserved for variables and the stack
- this combined memory footprint, which is the amount of memory that is allocated and reserved for running a process, is called the process image
- the instruction pointer is set to the first byte of the image

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

Jumps

A

Jumps to labels are replaced by real memory addresses. They point towards a physical location within the process image, and the instruction pointer is set according to this address when the jump is made.

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

Heap

A

Memory available for the programmer to reserve.

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

Compile-Time Address Binding

A

A program is assumed to always occupy the same area of memory every time it is executed. This means loops and jump locations are turned into fixed memory addresses during compilation. This has some disadvantages, for example, the program could not move memory locations nor allows other processes to use memory address occupied.

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

Load-Time Address Binding

A

A program can be loaded anywhere in memory using relative addresses, allowing more flexibility and setting jumps and locations to relative addresses. So instead of using things like JUMP 800, meaning the program would jump to memory address 800, we can use JUMP -8, meaning it will, if we say that every memory address is 4 bytes, jump backwards twice.

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

Dynamic (Run-Time) Address Binding

A

Essentially, a program can be stored anywhere with virtual addresses but the physical addresses will be determined at runtime based on the available memory. So the virtual addresses will map onto real addresses at run-time by the MMU.

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

Memory Allocation Examples

A

Between the datum and the limit (the start and end) of the memory locations, there will be fragmentations since there is always deallocation of data. There also could be starvation of processes in memory because they cannot load anywhere due to a large amount of small gaps. This leaves the memory manager with:
First fit -> choosing first free space that’s big enough
Best Fit -> choose the smallest free space that’s big enough
Worst Fit -> choosing biggest area of free space on purpose

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

50% Rule

A

For First Fit, if n amount of bytes of memory is allocated, then amount of unusable memory due to fragmentation becomes n/2.

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

Moving Processes

A

We can move processes to defragment space, which is only possible with relative addresses, but even with this, we have a finite number of memory for a finite number of processes, so memory will eventually fill up.

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

Swapping

A

The solution of allocation in memory. A process can be swapped out to disk to make more room when it is not being used. The disk reserves some of its space for these swaps, called swap space, which allows RAM to be freed up for processes which need it. However, accessing disk is a lot slower, and a system will a lot of processes in swap space will run a lot more slowly.

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

Static Linking

A

Copies of library code are added to the final program image as a program is using a third-party library subroutine (import etc).
Can result in large images and wasteful disk storage and memory space.

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

Dynamic Linking

A

A small stub is included in final program image, which tells the memory manager where to find library code and allows re-entrant library code to be shared between processes.

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

Dynamic Loading

A

An alternative to dynamic linking in which dynamic linking is controlled by the OS, but dynamic loading is controlled by the programmer, and allows a process to execute without required libraries being in memory since they can be attached to the process image while running.

17
Q

Segmentation

A

Allows individual parts of a process to occupy different memory locations, in which the process has a segment table (this includes the stack, main program, library; we cannot split the main memory into sections). This allows enhanced memory protected, and allows swapping between segments.

18
Q

Segment Sharing

A

If two processes run the same code with different values, we can have shared re-entrant code segments and have separate data segments, essentially creating a branch in the code.

19
Q

Intel Segment Registers

A

CS -> code segment
DS -> data segment
SS -> stack segment
ES -> extra segment
FS -> additional register
GS -> additional register
Remember: C,D,E,F,G,S

20
Q

Re-entrant Code

A

Code that doesn’t cause conflicts between multiple processes by not using shared resources.