1. Anatomy of process Flashcards
How the stack grows ?
It grows from high to low
What are the parts (pointers) of :
1. Memory stack
2. Registers
Memory :
1. SP
2. BP
Register:
1. General purpose registers for holding intermediate values
What are the parts of a process ?
- Stack
- Heap
- Data section
- Code/instruction section
What are the characteristics of a process ?
- Has a PCB
- Has a PC
- Has a unique id
Where is the program counter located and where is it pointing ?
It is located in the cpu and pointing to the current executed instruction in memory
What is a pointer function and where does it reside ?
Points to a memory address
It reside either in :
1. Stack
2. Data section
3. Heap
How many bytes an integer take in memory ?
32 bit system—> 4 bytes
64 —> 8 bytes
How many bytes does the cpu read when doing a memory access ?
Even though it asked for 4 bytes / 8 bytes (depending on system architecture) it will get 4 kb
What is a memory leak ?
A process allocate objects in the heap and never free them afterwards
What is a dangling pointer ?
Func 1 : has a pointer to x
Func 1 : called func 2
Func 2: has also a pointer to x
Func 2 pointer : free up x
Func 1: is pointing to something deallocated
Which is faster heap or stack ?
Stack is faster due to continuous memory allocation for local variables
What is escape analysis ?
Whenever possible allocate in the stack for local variable unless a variable/pointer has been returned it will be escape the stack and go to heap
Where does the process live at rest ?
It live at disk
What is the difference between sp and bs ?
Stack pointer move and change .
Base pointer provides us with a fixed reference.
When a stack overflow happens ?
- Large local variable
- Recursion