Loading...
Track who owns each memory region and how a logical address reaches storage. Distinguish page mappings, meaningful segments and the stack frames retained by nested calls.
What you'll be able to do
The OS needs information about allocated and available memory, process requirements and permitted access. It decides where suitable storage can be supplied and controls each process’s use under the system’s protection rules. Allocation metadata and address translation are part of memory management; a process cannot safely assume that every numeric address is its own writable RAM.
Paging divides virtual space into fixed-size pages and physical memory into matching frames. A page table maps a process’s pages to available frames and records relevant status/permissions. Logically adjacent pages need not occupy adjacent physical frames. For eight-byte pages, virtual address 38 has page number 4 and offset 6. If page 4 maps to frame 9, physical address is 9×8+6=78.
Segmentation divides a program into meaningful variable-sized regions, such as code, data or stack. In a simple segment model, a base and length let the system check whether an offset is valid before forming the physical address. A segment of length 24 has valid zero-based offsets 0 through 23; offset 24 must fail rather than access the following region.
Virtual memory gives a process a managed address space, with some pages potentially absent from physical RAM. A reference to an absent page can cause a page fault, after which the OS obtains the page, updates mappings and resumes appropriately. Accessing backing storage can be much slower than using resident RAM. Excessive page movement can dominate useful work, so virtual memory is not equivalent to unlimited fast physical memory.
A call-stack frame retains information needed by a particular unfinished subprogram call, such as return information, parameters and local values under the language/machine convention. If main calls f and f calls g, g’s frame is the current top while it runs. Returning from g removes its active frame and resumes f; returning from f resumes main.
Recursion creates separate unfinished frames even when the subprogram name repeats. Each invocation needs its own relevant local state. SP identifies a stack position according to the machine’s growth and pointer convention; it is not a count with one universal numerical update. Frame lifetime and the lifetime of objects referenced by it can differ. Draw the frames and return destinations before claiming that a local variable has one shared value across every call.
| Execution stage | Active frames, bottom→top | Next return goes to |
|---|---|---|
| main running | main | Its caller/system |
| f called | main, f | main |
| g called by f | main, f, g | f |
| g returns | main, f | main after f returns |
| f returns | main | Its caller/system |
Attempt the task before opening its worked response. Record each change of state, explain the rule used, and check the result against the original requirements. Code examples labelled Python 3 use that language’s conventions; pseudocode states its own assumptions.
Common mistakes to avoid
Key takeaways
Test yourself
Answer a few questions, then review anything you missed.
Start with the quiz above to check the key ideas. You can also choose another topic from the practice library.