Allocation of Runtime Memory and Virtual Memory Flashcards
Which command can we use to disassemble object code?
objdump -d ‘myFile.h’
What is a Single Task OS? Give a model of one…
An OS that only allows 1 user to perform 1 task at a time.
MS-DOS.
What is MS-DOS? What process does it follow to boot up?
A single task OS.
RAM BIOS is activated to load initial IO systems. Then Software BIOS launches the rest of the system.
What is a multi-task OS?
An OS that allows multiple users to perform multiple tasks at once. E.g Linux.
How does Linux utilise Virtual Memory for processing?
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.
What is a Page Table?
A data structure used by Virtual Memory within the OS to map Virtual Memory Addresses to Physical Memory Addresses.
Which component is responsible for mapping Virtual Memory Addresses to Physical Memory Addresses?
Memory Manage Unit within the Operating System.
What is the Stack?
A structure that holds the memory containing currently executing functions.
How and why does the stack grow?
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.
What are the 2 stack pointers? What are their roles?
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).
What happens to the pointers when a function is executed or returned?
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.
What is encapsulated in the function frames?
Memory address allocated to the function that holds the functions data.
What is the Heap?
Memory within the system that is for dynamic allocation.
When allocating from the Heap, from what position on the Heap is the memory taken?
From he bottom of the Heap (if possible).
Is it only contiguous memory that can be taken from the heap?
Yes, since hence why malloc can only return contiguous memory.
What happens if malloc reaches the top of the heap without finding suitable memory?
It cycles back to the bottom and starts searching up the heap again.
What are the 3 allocation policies of malloc when searching the heap?
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.
What does the malloc policies help prevent?
They help prevent wasted memory being caused by fragmentation. The different policies adapt different allocation specifications to pick up fragmented memory.
On a 64 bit machine, what format specifier do we use for the Stack Pointer and Base Pointer?
Frame Pointer -> %rbp
Stack Pointer -> %rsp
In ANSI C, what does __asm__ perform?
Assembler instructions.