Allocation of Runtime Memory and Virtual Memory Flashcards

1
Q

Which command can we use to disassemble object code?

A

objdump -d ‘myFile.h’

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

What is a Single Task OS? Give a model of one…

A

An OS that only allows 1 user to perform 1 task at a time.
MS-DOS.

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

What is MS-DOS? What process does it follow to boot up?

A

A single task OS.
RAM BIOS is activated to load initial IO systems. Then Software BIOS launches the rest of the system.

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

What is a multi-task OS?

A

An OS that allows multiple users to perform multiple tasks at once. E.g Linux.

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

How does Linux utilise Virtual Memory for processing?

A

Linux uses Virtual Memory to create more memory than physically available in order to increase memory for processes. Virtual memory is mapped to Physical Memory via the Pages and the Operating Systems Memory Management Unit.

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

What is a Page Table?

A

A data structure used by Virtual Memory within the OS to map Virtual Memory Addresses to Physical Memory Addresses.

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

Which component is responsible for mapping Virtual Memory Addresses to Physical Memory Addresses?

A

Memory Manage Unit within the Operating System.

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

What is the Stack?

A

A structure that holds the memory containing currently executing functions.

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

How and why does the stack grow?

A

The stack grows downwards from high addresses to low addresses.
The stack grows whenever a function is executed, and shrinks whenever a function is returned.

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

What are the 2 stack pointers? What are their roles?

A

Frame/Base pointer -> Points to the top frame of the currently executing function.
Stack Pointer -> Points to the bottom frame of the stack (currently executing function).

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

What happens to the pointers when a function is executed or returned?

A

Frame Pointer -> When executed it moves down to the top frame of the newly executed function. When returned it moves to the top frame of the function above.
Stack Pointer -> When executed, the pointer moves to the bottom frame of the new function. When returned, moves to the bottom frame of the above function.

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

What is encapsulated in the function frames?

A

Memory address allocated to the function that holds the functions data.

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

What is the Heap?

A

Memory within the system that is for dynamic allocation.

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

When allocating from the Heap, from what position on the Heap is the memory taken?

A

From he bottom of the Heap (if possible).

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

Is it only contiguous memory that can be taken from the heap?

A

Yes, since hence why malloc can only return contiguous memory.

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

What happens if malloc reaches the top of the heap without finding suitable memory?

A

It cycles back to the bottom and starts searching up the heap again.

17
Q

What are the 3 allocation policies of malloc when searching the heap?

A

Best Fit -> Searches for the tightest fit. However, leaves little room for contiguous re-allocation.
First Fit -> Searches for the first memory fit, regardless of size. However, can lead to wasted memory allocation.
Next Fit -> Looks for the next fit after the first fit pointer.

18
Q

What does the malloc policies help prevent?

A

They help prevent wasted memory being caused by fragmentation. The different policies adapt different allocation specifications to pick up fragmented memory.

19
Q

On a 64 bit machine, what format specifier do we use for the Stack Pointer and Base Pointer?

A

Frame Pointer -> %rbp
Stack Pointer -> %rsp

20
Q

In ANSI C, what does __asm__ perform?

A

Assembler instructions.