Unit Iii-1
Unit Iii-1
Unit Iii-1
Main Memory:
Main memory, commonly referred to as RAM (Random Access Memory), is the computer's
primary temporary storage for actively processed data.
Unlike permanent storage like hard drives, RAM is volatile, losing its contents when the
computer powers down.
It's organized into addressable cells, each holding data measured in bytes.
Some of the major functions fulfilled by memory management are discussed below.
Memory Allocation
Memory management ensures that the needed memory space is allocated to the new process
whenever a process is created and requires memory. Memory Management also keeps track
of the system's allocated and free memory.
Memory Deallocation
Like memory allocation, whenever a process completes its execution, memory management
ensures that the space and the memory resources it holds are released. Any newly created
process can use the freed memory.
Memory Sharing
Memory sharing is also one of the main goals of memory management in OS. Some
processes might require the same memory simultaneously. Memory management ensures
that this is made possible without breaking any authorization rules.
Memory Protection
Memory Protection refers to preventing any unauthorized memory access to any process.
Memory management ensures memory protection by assigning correct permissions to each
process.
Logical Address
It is a virtual address generated by the CPU while a program is running. It is referred to as a
virtual address because it does not exist physically.
Using this address, the CPU access the actual address or physical address inside the
memory, and data is fetched from there.
The set of all logical addresses generated by the CPU for a program is called the logical
address space.
Physical Address
Physical Address is the actual address of the data inside the memory.
The logical address is a virtual address and the program needs physical memory for its
execution.
The user never deals with the Physical Address. The user program generates the logical
address and is mapped to the physical address by the Memory Management Unit (MMU).
The set of all physical addresses corresponding to the logical addresses in the logical
address space is called the physical address space.
Comparison between Logical Address and Physical Address
The set of all logical addresses The set of all physical addresses corresponding to the
generated by the CPU is called the logical addresses in the logical address space is called
logical address space. the physical address space.
MMU is a hardware device that does the run-time mapping from the virtual address
to the physical address. It is located within the Central Processing Unit.
Let us understand the concept of mapping with the help of a simple MMU scheme and that
is a base-register scheme.
In the above diagram, the base register is termed the Relocation register.
The relocation register is a special register in the CPU and is used for the mapping of
logical addresses used by a program to physical addresses of the system's main
memory.
SWAPPING:
The area of the secondary memory where swapped-out processes are stored is
called swap space.
In the case of high-priority processes, the process with low priority is swapped out of
the main memory and stored in swap space then the process with high priority is
swapped into the main memory to be executed first.
The main goals of an operating system include Maximum utilization of the CPU.
This means that there should be a process execution every time, the CPU should
never stay idle and there should not be any Process starvation or blocking.
There are two important concepts in the process of swapping which are as follows:
Swap In
Swap Out
Swap
In:
The method of removing a process from secondary memory (Hard Drive) and
restoring it to the main memory (RAM) for execution is known as the Swap
In method.
Swap Out:
It is a method of bringing out a process from the main memory(RAM) and sending it
to the secondary memory(hard drive) so that the processes with higher priority or
more memory consumption will be executed known as the Swap Out method.
Note:- Swap In and Swap Out method is done by Medium Term Scheduler(MTS).
Advantages of Swapping in OS
The advantages of the swapping method are listed as follows:
Disadvantages of Swapping in OS
There are some limited disadvantages of the swapping method which are listed as follows:
If the system deals with power-cut during bulky swapping activity then the user
may lose all the information which is related to the program.
If the swapping method uses an algorithm that is not up to the mark then the number
of page faults can be increased and therefore this decreases the complete
performance.
There may be inefficiency in a case when there is some common resource used by the
processes that are participating in the swapping process.
o Simple to implement.
o Easy to manage and design.
o In a Single contiguous memory management scheme, once a process is loaded, it is
given full processor's time, and no other processor will interrupt it.
o Wastage of memory space due to unused memory as the process is unlikely to use all
the available memory space.
o The CPU remains idle, waiting for the disk to load the binary image into the main
memory.
o It cannot be executed if the program is too large to fit the entire available main
memory space.
o It does not support multiprogramming, i.e., it cannot handle multiple programs
simultaneously.
Multiple Partitioning:
o The single Contiguous memory management scheme is inefficient as it limits
computers to execute only one program at a time resulting in wastage in memory
space and CPU time.
o The problem of inefficient CPU use can be overcome using multiprogramming that
allows more than one program to run concurrently.
o To switch between two processes, the operating systems need to load both processes
into the main memory.
o The operating system needs to divide the available main memory into multiple parts
to load multiple processes into the main memory.
o Thus multiple processes can reside in the main memory simultaneously.
Fixed Partitioning
The main memory is divided into several fixed-sized partitions in a fixed partition
memory management scheme or static partitioning.
These partitions can be of the same size or different sizes. Each partition can hold a
single process.
The number of partitions determines the degree of multiprogramming, i.e., the
maximum number of processes in memory.
These partitions are made at the time of system generation and remain fixed after
that.
o Simple to implement.
o Easy to manage and design.