Paging (5+6) Flashcards
Advantages of partial loading
many processes can concurrently be maintained in main mem (only a few pages for each processes)
Allows users to execute many programs and large data structures at once without worrying about filling up main memory
more processes = efficient utilization of CPU
Page
small chunk of memory that constitutes a small part of the total memory needed to execute a process - one process may have many pages
Page table
look up table used by MMU to decide how many pages should be swapped in and swapped out of main mem
name and explain the 2 different parts of the MMU used in memory translation and assignment
Virtual memory manager - retrieves processes in secondary storage for transfer
Page table translates VA to PA - page table hard coded into cache mem and only accessible by OS kernel
What are the three things that can happen when a process at a VA is translated to a PA
- Physical address is assigned to process by page table
- Memory page is not accessible to MMU as it is still in secondary storage
- Nothing - VA is invalid
Demand paging
pages are allocated (on demand) to free frames in main memory
“on demand” means that when a process is scheduled to run, then the memory pages (needed by process to run) will be allocated to free frames in main mem - no free frames, pages of other process will be eviced to create free space “frames”
how does the MMU accomplish the “illusion” that each processes has access to all the required phys mem space?
MMU uses demand paging - pages most in demand are swapped in and least demanded pahes are swapped out. Priority processes are kept in temp mem cache for fast access and retrieval
Context switching
process of swapping in and out parts of a process between VM and PMem
What does context switching allow the OS to do?
OS can keep active portions of multiples processes in main mem while the rest of the process is in VM
when does context switching happen
when we switch between user and kernel operations - when we need to let the OS swap a process into main mem for execution or to suspend it.
Context switch is an OS level software interrupt
Each process is allocated memory that is comprised of
code - compiled source code
data - any data e.g. external files used by the process
stack - used for static memory allocation
heap - dynamic mem allocation
this is the process address space
Difference between stack and heap regarding position
stack - starts at max logical position and grows down
heap - starts at min logical position and grows up
What is stack
region in mem that stores temp variables created by each function in a program - LIFO
When function exits variables are freed - now available for other stack variables
advantage of stack
memory is managed for the user - doesnt have to free or allocate it
Heap
not managed automatically
larger free-floating region in memory
need to use malloc() or alloc() and free( )
Explain issues with swapping chunks
Frequent swapping - OS context switches - during context switch, the CPU is temporarily unused (MMU needs to context switch a few times so that a suitable number of mem chunks have been swapped into main mem)
Mem fragmentation
wasted space
name and explain the 2 different types of fragmentation
Internal: wasted memory within chunks - too much main memory allocated for corresponding vMem chunk
external: free gaps between mem chunks in phys mem
Benefit of paging
MMU can have fine grained control over what parts of a process is currently running and have many processes lloaded into phys mem at one time
Solution to fragmentation
paging
Paging
Mem management scheme whereby a computer stotes and retrieves pages from secondary storage for use in main memory
Suitable page size
debate
larger pages = increase in fragmentation
How to implement paging
key data structure - page table
For each process, there is a pt in main mem
1.) Check that a page can fit in the pt - no: MMU executes a page already in pt to make space
Offset
offset from the VA is copied to the PA to indicate how large the page is and how much mem of a mem chunk must be allocated at each frame (phys mem address)
PTE (page table entry)
ith entry (row) of a page table and is a pointer to an actual mem page - also includes a set of permission bits
valid bit 0 vs 1
1 - page is in memory (PTE points to a page in physical memory)
0 - page not in mem and must be swapped in from virt mem
dirty bit
tells MMU whether the page has been modified by processor or not
relationship between PT size and address space
address space increases = PT size increases