Please enable JavaScript.
Coggle requires JavaScript to display documents.
1.4. Memory Management - Coggle Diagram
1.4. Memory Management
Dynamic Memory Allocation (динамическое выделение памяти)
- Program don't know how much of memory it'll need.
System libraries
- operating systems and/or system libraries offer special functions with which programs can allocate and release memory.
System must keep track of which memory areas have already
been allocated and which are still free
so it leads to.....
Fragmentation
- Frequent requesting and releasing of memory
leads to a problem called memory
- there may happen small chunks of free memory. As an allocated memory region must always be contiguous, they can no longer be used for handling large blocks allocation requests !
so to avoid....
allocation strategy
- To avoid such situations, leads to as
little fragmentation as possible
(page 28)
"First fit"
ADVANTAGE:
- simple & fast
DISADVANTAGE:
- small free chunks accumulate at small addresses
-
"Best fit"
DISADVATAGE:
- Accumulation of
many small residual gaps
"Worst fit"
ADVATAGE
- gaps remains large so it's easy to allocate them
Memory Protection and Multitasking
- multitasking systems where several processes can be in main memory. This ensures that the processes can only access their own address area. This means that the other processes running are
safe and can continue running unharmed.
1) OS is granted each process only one contiguous address (выделенное место на процесс)
after what....
2) For memory protection hardware support is needed:
- The CPU must be able to recognize a process using an
address that is not in its valid address range
! if an address is not valid - memory access violation !
- CPU switches to OS, and OS stop the process.
-
Virtual Memory Addresses
Paging
- method of memory management, where the main memory id divided into pages (form of tables) and managed by OS and MMU.
3 steps......
-
Page frames
- Blocks, divided analogously in the main memory (RAM)
Page tables
- in paging address translation is performed via page tables
(table on page 32)
Virtual addresses
- addresses generated by CPU
Address offset (смещение)
- frame address has the same offset as virtual address has
- address offset has to be added to the frame’s start address to obtain its
physical address.
Demand Paging (also known as virtual memory management)
- much larger memory space provided by
a hard disk
Example: code and data aren't immediately loaded into main memory completely when a new process is started. They're loaded as soon as they are accessed for the first time.
Replacement Strategies
First in/first out (FIFO)
- The page that has been in the main memory for the longest amount of time is replaced.
Least Frequently Used (LFU)
- The page that is least frequently used is replaced.
Least Recently Used (LRU)
- The page that has not been accessed for the longest
amount of time is replaced
Not Recently Used (NRU)
- THE BEST! easy, little effort
- sets flags:
-
-
-
-