memory management Flashcards
Memory management is needed even though memory is getting cheaper as applications are demanding more and more. The OS must time inputs and outputs well to maximise CPU efficiency as these are needed in memory management.
- why is memory management needed?
2. how does the OS overcome the issues that can be caused by memory management?
- describe the 5 considerations of memory management
memory management needs to consider:
relocation- memory references must be translated to physical in the event of returning to RAM in a different place
protection- absolute addresses must be checked at runtime so a process doesn’t reference another processes memory
sharing- several processes from the same application should have access to the same portion of memory
logical organisation- segmentation is needed to split programs into modules for different protection levels
physical organisation- overlaying allows various modules to occupy the same region of memory but this is time consuming to code
- what is partitioning?
- give 2 disadvantages of equal portions
- give 1 advantage of unequal portions
- give 2 cons of fixed partitioning
partitioning is a method of memory management that was used before virtual memory. It could be fixed or dynamic.
fixed partitions could be equal but this meant some programs didn’t fit meaning overlaying was necessary, and memory use was inefficient resulting in internal fragmentation
fixed partitions could be unequal to accommodate larger and smaller programs, reducing internal fragmentation.
fixed partitioning means that the number of active processes is limited and a large number of very small processes wouldn’t use space efficiently.
- give 1 advantage of dynamic partitioning
2. describe three ways the OS can choose to allocate blocks.
in dynamic partitioning the partitions vary in length and number, each process is allocated exactly how much memory as required. Any fragmentation is external and can be resolved with compaction.
The OS chooses which free block to allocate:
best-fit: chooses the block closest in size to request. Worst performer overall and compaction needs to be done frequently
first-fit: chooses first block that’s large enough. Fast.
next-fit: scans memory from last placement, often allocating at the end of memory where the largest block is. compaction is needed to obtain this block
- what is paging?
- what is segmentation?
- where do the pages/segments need to be?
- what is a resident set?
in paging memory is divided into equal sized chunks. The chunks of memory are frames and the chunks of the process are pages. The OS maintains a paging table.
In segmentation a program is subdivided into varying lengths up to a maximum. it is similar to dynamic partitioning.
It isn’t necessary for all pages/segments to be in main memory during execution. If the next instruction and data location are execution can proceed.
resident set= portion of process that is in main memory
- give 2 virtual memory pros
- give one thing that can go wrong using virtual memory and what is done to help prevent it
- what is the principle of locality
- what are requirements for virtual memory
advantages of virtual memory is that more processes can be maintained in main memory, and a process is able to be larger than all of main memory.
thrashing is a state when the system spends more time swapping pieces than executing. To prevent this the OS guesses which pieces will be used soon based on history.
The principle of locality is the tendency of a processor to access the same set of memory locations repetitively over a short period of time.
In order for virtual memory to work the hardware must support paging and segmentation and the OS must be able to manage it.
- what 3 pieces of information is kept in the page table?
- where are page tables stored?
- describe inverted page tables
each page table entry has a frame number, a bit indicating if the page is in main memory, and a bit indicating if the contents has been altered since its last load.
Page tables are stored in virtual memory and the part that is currently needed is in main memory. They grow proportionately.
inverted page tables map the page number to a hash which in turn points to an inverted page table so a fixed portion of real memory is used regardless of the number of processes
- describe the memory management in unix systems and how its developed over time
- what does SVR4 use?
unix was intended to be machine independent so memory management techniques vary.
Earlier systems used variable partitioning with no virtual memory, but recent ones use paged virtual memory.
SVR4 uses paging and a kernel memory allocator for allocating memory for the kernel.