Memory Management. The current methods are based on memory management that was used in the past.
Programs must be brought into memory and become processes to be executed. Input Queue – A collection of programs on disk waiting to be brought into memory for execution.
The part of the operating system that manages memory is called the memory manager. Main memory is a repository of data that is quickly accessible and shared by the cpu and I / O devices.
Functions: What memory is being used, who uses it, what processes can be loaded, allocation and memory releases.
When a program is loaded into main memory it becomes processes.
The techniques that exist for loading programs into memory are: fixed partition, which is the division of free memory into several parts (of equal or different size) and dynamic partition, which are memory partitions in sizes that They can be variable, depending on the amount of memory each process needs.
Among the main operations that memory management performs are relocation, which involves moving active processes in and out of main memory to maximize processor utilization; protection, mechanisms that protect processes that are running from interference from other processes; code and data sharing, so the protection mechanism allows certain processes in the same program that share a task have memory in common.
[ hide ]
- 1 Linking instructions and data to memory
- 1 Example:
- 2 Contiguous allocation
- 3 Assignment with multiple fixed partitions
- 4 Assignment with variable partitions
- 5 Dynamic memory allocation problem
- 6 Virtual storage
- 7 Swap / Swap
- 8 FOUNDATIONS OF VIRTUAL MEMORY
- 9 VIRTUAL STORAGE
- 10 PAGE
- 11 Sources
Linking instructions and data to memory
They can be carried out in three stages:
- Compilation time: if the memory location is previously known, absolute code can be generated, the code must be recompiled if the start address changes.
- Load time: If the addresses are known at compile time, relocatable code must be generated.
- Execution time: The binding is delayed until the run time if the processes can be moved during their execution from one memory location to another.
Overlays (Overlays) – Keeps in memory only those instructions and data that are required at a certain time – It was used when the process was greater than the amount of memory allocated to it – It was implemented by the user, no special support was required of the operating system, its programming was complex.
Formerly the programs did not run if it did not have the required memory, today it can because it is loaded in parts.
Cobol is written by sections, Overlays is a section.
- Generally the main memory has two partitions.-For the resident operating system that can be placed in low or high memory according to the location of the interrupt vector -User processes are placed in another partition
- Single partition assignment
– The relocation log scheme is used to protect user processes from each other, and to protect OS code and data. – The location record has the value of the smallest physical address; registration limit…
- Assignment with multiple partitions
-Hole: Block of available memory; Multiple gaps (partitions) of different sizes are established through memory. -When a process arrives, it is assigned to a slot large enough to contain it. -The OS maintains information about the assigned partitions.
Assignment with multiple fixed partitions
Default user-configured partitions are used in OS / 360 / MFT (multiprogramming with a fixed # of tasks). Relocation: The linker must determine which addresses to reposition vs. Absolute load x part.
Protection: 2K blocks with key, or Base and limit register. FRAGMENTATION. overlays cannot be applied in this memory management scheme Protection systems: -log limit and base -protection by key internal fragmentation: waste of memory spaces.
Assignment with variable partitions
The size of the partition is set at the time of loading the program and depending on its size.
The processes have to run in contiguous memory. It has an external fragmentation problem, due to the gaps that remain after execution; The solution is to move the process, which are running, compression process. Condensation: Fusion of two adjoining voids.
The current memory management scheme is born from the previous two. Pagination and segmentation are born.
Dynamic memory allocation problem
How to satisfy the request for a size from free gaps Placement strategy:
- – Worst fit: Largest gap
- -Next adjustment
- -Most sophisticated strategy : Buddy System-Lists of holes with power sizes of 2
The first setting and the best setting are better than the worst setting in terms of storage speed and utilization.
- Ability to access addresses in much larger storage space than is available in the system’s primary storage.
- SO Atlas, Manchester 1960
- Decoupling the addresses (V) referenced by a running process from the addresses available in the primary storage (R)
- Process calculated addresses not necessarily available on primary storage
- Real address: address available in memory.
- Virtual address: addresses used by processes.
To efficiently pass programs from swap memory to main memory, it must be done by hw
Exchange / Swap
- A process can be temporarily swapped from memory to backup storage and can then be taken back into memory for execution.
- Backup storage is done on disk, which must be fast and have enough space to locate a copy of all memory images for all users; You must provide direct access to these memory images.
- Download (swap out), load (swap in) – Exchange variant in priority planning algorithms; low priority processes are taken out of memory so that the highest priority process can be loaded and executed
- Most of the time is transfer time; this is directly proportional to the amount of memory exchanged.
- There are modified exchange versions of the different systems, such as Unix, Linux and Windows .
FOUNDATIONS OF VIRTUAL MEMORY
The processor uses and generates virtual addresses.-Part of the memory map (virtual) is on disk (swap) and part in main memory-The MMU (memory management unit) translates the virtual addresses into physical ones. -The MMU produces a page fault (trap) when the address is not in main memory. -The OS deals with the page fault, making a transfer between the main memory and the swap area (swap disk)
In the MMU scheme, the value of the relocation register adds to each address generated by the user process when it is sent to memory. The user program was concerned with logical addresses; I never had to worry about physical addresses.
Virtual address space, V: address space that can be referenced by a process Real address space, R: Available physical storage, generally V >> R Dynamic Address Translation (DAT): V ===> R Address translation correspondence map: by blocks: = s pages, <> segment. Two-dimensional addressing : Block, offset Paging: Division of memory and programs in equal sizes.
Segmentation: Division of memory into sizes corresponding to the components of the program and the programs are divided into their basic components (eg, sub-routines) “The pagination is to the fixed partition as the segmentation to the variable partitions” The virtual storage of a user does not have to be contiguous even in secondary storage.
Working set: Set of code lines loaded in real memory needed to perform a given task (not all lines of program code are needed to perform a task )
The logical address space of a process is not necessarily contiguous; the processes are located in physical memory where they are then available. Physical memory is divided into blocks of fixed size called frames (sizes with powers of 2 between 512 bytes and 8192 bytes).
Logical memory is divided into blocks of the same size called pages. The trace of all frames is kept. To run a program of size n pages, you need to find n free frames and load the program.
A table must be developed to translate the physical addresses into logical ones. Internal fragmentation may occur.