I know that every running process has pages associated with it in virtual memory and few of them will be loaded into main memory as required. I also know that program will have a stack and also a heap to allocate dynamic memory. Here are my questions.
- Is stack also part of some page in main memory?
- What happens when the program is moved to waiting state? Where are the stack pointer, program counter and other info stored?
- Why stack grows down and heap grows up?
- Can L1, L2 cache contain only one chunk of contiguous memory, or can it have some part of stack and heap?
Can you recommend any good book that covers these things?