chapter 7 Flashcards
fundamental strategies used in MM
1- placement strategy
2- fetch strategy
3- replacement strategy
bitmap / bit vector
a mem divided into units of same size. a bitmap represent whether a segment of mem is free 0 or allocated 1.
linked list for mem management
the linked list is stored in the free mem itself
1- placement strategy: list-based (used within a process)
these strategies focus on how holes in the list, which represent free mem, are sorted and utilised during mem allcocation. Hole lists are sorted differently:
- first fit: sorting by mem @, first large enough hole is chosen
- rotating first fit / next fit: sorting by mem @, similar to first fir by the search starts from the last allocated hole
- best fit: sorting by hole size, smallest hole first
- worst fit: sorting by hole size, largest hole first
problem with this strategy is fragmentation
1- placement strategy: buddy system (used by the OS)
allocates mem by splitting mem into partitions of size that are 2^n. when a mem request is made, system attempts to find smallest available partition (best fit), if the partition is too large, it gets split into 2 smaller buddies, it keeps splitting until an appropriate partition size is obtained.
if 2 buddies are free, they could be merged back
external fragmentation
occurs outside the allocated mem areas, typically happens with list-based strategies (best fit, first fit) and also with buddy systems.
internal fragmentation
occurs within the allocated mem areas, typically happens when more mem is allocated than whats needed, leading to wasted space inside the allocated block
swapping
addresses within a process are statically bound, they can only be loaded in the same place in main mem from where they were swapped out.
- solution: static partitioning of the main mem. main mem is split into partitions where each process run in one partition. processes swapped back in should be placed in the same partition they were in before
- solution: program relocation.
segmentation
mapping logical @ to physical @ space. size of segments is variable. segmentation allows different segments of a program, such as data, code, stack to be placed in different parts of physical mem
paging
organising logical @ space
compacting
is shen segments of mem are moved closed together to close gaps
Page table
It contains a presence bit (valid bit). If its = 1, then the page is present in mem. If it is 0, page isn’t in mem, triggering a page fault.
A page fault is triggered when a program tried to access a page that’s not loaded in physical mem.
Inverted page table has a single table for the entire system. Each entry in this table corresponds to a physical page frame and contains a PID and logical @
What happens when a page fault occur?
1- a trap is triggered alerting the OS that the required page isn’t in mem
2- the OS then loads the missing page from secondary mem into physical mem
3- once the page is loaded, the mem access that triggered the page fault is called again
Translation lookalike buffer TLB
Is a speciliased hardware cache, it stores recent translations of virtual @ to physical ones, allowing for faster lookups. When there is a TLB hit, meaning the required page info is found in TLB, no additional mem access are necessary. When there is context switches, TLB content must be updated which is known by TLB flush. If a page is accessed that’s not in TLB, the page access info is entered in TLB.
Absolute, static and dynamic linking
Absolute linking: addresses are fixed at compile time, this means that the program can only run correctly if it is loaded at a specific memory location.
Static linking: during the loading or starting of the program, addresses are relocated, this allows the program to be loaded into different memory locations.
Dynamic linking : the code accesses generally operands indirectly, this allows the program to be moved in memory at any time.