Memory Management (PPT 5 - 6) Flashcards
Can we extend main memory using a hard disk?
Yes, this is virtual memory. However, it is still slow.
What governs memory address and register usage?
The program code being run.
Why use memory management?
The Operating System needs to allocate memory as efficiently as possible and keep track of those sector of memory which are free and which are in use (And what process is using each section)
What is memory management?
Management is needed to handle memory resources of a computer as efficiently as possible. It is partly static and partly dynamic and is governed by the OS, with hardware support from the processors.
What are the aims of memory management?
Primary function is to bring processes and data from secondary storage to main memory ready for execution. The following aims are desirable:
Protection
Sharing
Relocation
What is Sharing?
In a multi user and multi program environment, the same data can be used multiple times. It is therefore memory efficient if only one copy is stored and shared between processes.
What is Protection?
We need to prevent unauthorised programs accessing areas of memory allocated to other processes. This means the OS must protect processes (“Fence off” memory areas)
What is Relocation?
A process must be capable of being loaded into any part of the address space. This means data pointers and branch pointers within the program can be accessed in a relative way, using their base address (start address of the program), and a logical way, which is relative to the base address. This is done by the compiler
How is memory allocated?
When a process is loaded, it must be placed into memory as efficiently as possible. If insufficient free memory is available, we must remove another process to free memory.
What are the four partitioning schemes?
- Fixed Size Partition
- Variable Size Partition
- Segmentation
- Paging
What are Fixed Size Partitions?
When a process is loaded, it is placed into the smallest free partition which can fit all of it. If no segments are free, a process is then unloaded
What are the key points of Fixed Sized Partitions?
- There is always memory wasted at the end of a segment
- When a process is unloaded, the whole segment is freed
- Data structures can grow but there is a limit
What are Variable Size Partitions?
When a process is loaded in, it is placed in the first available partition which can fit all of it. If no segments are free, memory is unloaded.
What are the key points of Variable Size Partitions?
- No memory is wasted when loading processes
- As time goes on, memory becomes fragmented. Possible to defragment but this takes time.
What is Segmentation?
When a process is loaded in, it is itself segmented in order to fit into all available memory spaces
What are the key points of Segmentation?
- Fragmentation is eliminated but the process itself becomes fragmented (not an issue if we keep track of fragments)
- Data structures that grow and shrink can be handled more easily
- Different protection properties can be given to each segment
- Hardware support in current CPUs
What is Paging?
When a process is loaded in, it is divided into relatively small fixed-size pages. Memory is divided into frames of the same size. Process pages are loaded into the minimum required frames
What are the key points of Paging?
- At most, a fraction of one frame is wasted when a process is loaded
- When a process is unloaded the space is freed in page sized sections, so is readily re used by the next process
- The frames used by a process need be contiguous in memory, so relocation is easy
- There is some fragmentation but it does not get worse over time.
What is a major benefit of using Pages?
We only need to load the page actually being processed into memory. This means that:
- We can start running a process as soon as the first page is loaded.
- We can have pages from many processes inn main memory, maximising the multi processing capabilities
- We can run processes that are actually larger than main memory
Is there a clear better Partitioning scheme?
No, each partitioning scheme has its advantages and disadvantages. Operating systems generally only use one scheme.
What is MMU?
Memory Management Unit
There must be a map between the address requested by the CPU and the actual page which stores that data. The MMU uses a page translation table to information about memory contents, such as which frames are used and which pages they contain.
What does the mapping process do?
The mapping process converts the logical address from the CPU into a physical address by looking up the page translation table
What is the difference between large and small pages?
Large pages contain more addresses within them but there is usually less of them. While smaller pages contain fewer addresses but there are more of them
How do you find the physical address of a page?
You first take the address offset which is where the memory address is in relation to the start of the page. You then take the page number and replace this with the frame which it is contained within. these two parts create the physical address