Memory management is the operation of a program that operates or manages primary memory and moves processes back and forth between large memory and disk during execution. Memory management saves each piece of memory, whether given a specific process or free of charge. It determines how much memory should be allocated to processes. It decides which process will receive the memory at any time. It tracks whenever a particular memory is released or shared and similarly revives the situation.

This tutorial will teach you the basic concepts related to Memory management.

Space Address Process

The address of a process address is a collection of logical addresses that the process refers to in its code. For example, when referring to 32-bit addressing, addresses can range from 0 to 0x7fffffff; that is, the potential 2 ^ 31 numbers, with a total theoretical size of 2 gigabytes.

The operating system takes care of counting logical addresses to physical addresses during memory allocation to the system. There are three types of addresses used in the program before and after the memory is allocated

Memory and Description Addresses

1. Symbolic addresses

Addresses used in source code. Variable words, constants, and instructional labels are the basic elements of a symbolic address space.

2. Relative addresses

During merging, the compiler converts symbolic addresses into related addresses.

3. Portable addresses

Uploader makes these addresses at a time when the program is loaded into a large memory.

Virtual and physical addresses are the same in schemes that include time and time loading time. Virtual and physical addresses are different from the time-bound address binding scheme.

A set of all logical addresses generated by the system is referred to as a logical address space. A collection of all existing addresses associated with these sensible addresses is referred to as a local address point.

The working time map from virtual address to address is generated by the memory management unit (MMU) which is a hardware device. MMU uses the following process to convert a virtual address into a real address.

  • The value in the base register is added to all addresses generated by the user process, which is treated as an offset at the time it is sent to the memory. For example, if the value of the basic register is 10000, then the user's effort to use the 100 address space will be redistributed to 10100.
  • The user system works with real addresses; never seen real addresses.

Static vs Dynamic Loading

The choice between Static or Dynamic installation will be made during the computer program being performed. If you have to load your system statistically, at the time of integration, complete programs will be integrated and connected without leaving any external system or module dependencies. The link combines the object program with the other required modules into a complete program, including logical addresses.

When you write a dynamically loaded program, your compiler will integrate the program with all the modules you want to forcefully install, only the references will be provided and all work will be done during the execution.

During upload, with a constant upload, the entire program (and data) is loaded into memory to begin processing.

When using dynamic uploads, powerful library channels are stored on disk in a portable format and are loaded into memory only when needed by the system.

Static vs Dynamic connection

As mentioned above, when a fixed link is used, the linker integrates all the other modules required by the system into a single functional system to avoid any dependency on operating time.

When dynamic linking is used, it is not necessary to link the actual module or library to the program, instead it provides a powerful module reference during integration and linking. Dynamic Link Libraries (DLL) for Windows and Unix Shared Items are excellent examples of powerful libraries.

Swappig 

An exchange is a way in which a process can be temporarily switched out of a larger memory (or moved) to a second storage (disk) and made that memory available to other processes. Over time, the system switches back the process from secondary storage to large memory.

Although functionality is often affected by the exchange process, it also helps with the performance of many large and similar processes and that is why Swapping is also known as the memory processing process.

The total time taken by the exchange process includes the time it takes to move the entire process to a second disk and copy the process back to memory, as well as the time it takes to retrieve large memory.

Let us assume that the user process is the size of 2048KB and on a standard hard disk where the conversion will take place there is a data transfer rate of about 1 MB per second. The actual 1000K process transfer to or from memory will take

2048KB / 1024KB per second -  = 2 seconds - = 2000 milliseconds

Now if you look at the time in and out, it will take a total of 4000 milliseconds and more where the process competes to get the largest memory.

Memory Distribution

The main memory usually has two dividers -

  • Low Memory - The operating system remains in this memory.
  • High memory - User processes are stored in high memory.

Memory Allocation and description

One division assignment

In this type of assignment, the site registration system is used to protect each other's processes, as well as to modify application code and data. The transit register contains the smallest local address value and the boundary register contains a list of valid addresses. Each logical address must be at the bottom of the boundary register.

Assignment of multiple divisions

For this type of assignment, the primary memory is divided into numerical segments where each division should have only one process. When the partition is free, the process is selected from the input line and loaded into the free partition. When the process ends, the separation is achieved by another process.

Fragmentation

As processes are loaded and deleted from memory, the free memory space is divided into smaller pieces. It happens later that processes cannot be shared on memory blocks given their small size and memory blocks remain unused. This problem is known as Fragmentation.

Divided into two types -

External Fragmentation

Complete memory space is sufficient to satisfy an application or to stay processed in it, but it is not compliant, so it cannot be used.

Internal Fragmentation

The memory block given to the process is huge. Some part of the memory is left unused, as it cannot be used by another process.

The following diagram shows how fragmentation can cause memory loss and the integration process can be used to create free memory in addition to partitioned memory -

External partitions can be reduced by compressing or mixing the memory content to put all the free memory together in one large space. To make the reunion possible, relocation must be robust.

Internal separation can be reduced by successfully providing a very small but large enough separation in the process.

Paging

The computer can process more memory than the physical value of a system. This additional memory is actually called visual memory and is the hardness level set to mimic computer RAM. Measurement techniques play an important role in the use of visual memory.

Page creation is a memory management method where the process address space is divided into blocks of the same size called pages (size 2, between 512 bytes and 8192 bytes). Process size is measured by the number of pages.

Similarly, the main memory is divided into small limited memory blocks (portable) called frames and the frame size is retained the same as that of the page in order to make the best use of large memory and avoid external partitions.

Address Translation

A page address is called a valid address and is represented by a page number and offset.

Logical address = Page number + and page offset

A private address is called a local address and is represented by a frame number and offset.

Physical Address = Frame number + page derived

The data structure called the page map table is used to track the relationship between the process page and the frame in visual memory.


When a program assigns a frame to any page, it translates this logical address into a local address and creates a table entry for the page to be used throughout the system.


When the procedure is performed, its corresponding pages are loaded into any available memory structures. Suppose you have an 8Kb system but your memory can only hold 5Kb in a given space at a time, the idea of ​​paging will be evident. When the computer runs out of RAM, the operating system (OS) will move inactive or unwanted memory pages to a second memory to free up RAM in other processes and restore them when needed by the system.


This process continues during the entire process while the OS continues to delete inactive pages from the main memory and rewrite them to a second memory and revert if the program is needed.


Pros and Cons of Page

Here is a list of the pros and cons of paging -

  • Page creation reduces external fragmentation, but still deals with internal fragmentation.
  • Page creation is easy to use and is considered an effective memory management process.
  • Because of the equal size of the pages and the frames, the exchange becomes much easier.
  • The page table requires more memory space, so it may not be suitable for a system with less RAM.

Separation

Separation is a method of memory management in which each task is divided into different parts of different sizes, one for each category containing fragments performing related functions. Each component is actually a separate area of ​​program addresses.

When the process is performed, its corresponding parts are loaded into unmodified memory even though all components are loaded into the available memory block.

Split memory management works similar to advertising but here the components are of varying lengths there as page pages in the default size.

The program component contains the main application function, application functions, data structures, and so on. The operating system keeps a map table in the entire process and a list of free memory blocks with numbers of parts, their size and associated memory locations in large memory. In each section, the table keeps the first address of the part and the length of the section. Memory location reference includes value indicating segment and offset.

All Topics of OS.