0% found this document useful (0 votes)
24 views7 pages

Unit 3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views7 pages

Unit 3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

What is a Logical Address?

A logical address, also known as a virtual address, is an address generated by the


CPU during program execution. It is the address seen by the process and is relative to
the program’s address space. The process accesses memory using logical addresses,
which are translated by the operating system into physical addresses. An address that
is created by the CPU while a program is running is known as a logical address.
Because the logical address is virtual—that is, it doesn’t exist physically—it is also
referred to as such. The CPU uses this address as a reference to go to the actual
memory location. All logical addresses created from a program’s perspective are
referred to as being in the “logical address space”. This address is used as a
reference to access the physical memory location by CPU. The term Logical Address
Space is used for the set of all logical addresses generated by a program’s
perspective.
What is a Physical Address?
A physical address is the actual address in the main memory where data is stored. It is
a location in physical memory, as opposed to a virtual address. Physical addresses
are used by the Memory Management Unit (MMU) to translate logical addresses into
physical addresses. The user must use the corresponding logical address to go to the
physical address rather than directly accessing the physical address. For a computer
program to function, physical memory space is required. Therefore, the logical address
and physical address need to be mapped before the program is run.

Similarities Between Logical and Physical Addresses in the Operating System


 Both logical and physical addresses are used to identify a specific location in
memory.
 Both logical and physical addresses can be represented in different formats, such
as binary, hexadecimal, or decimal.
 Both logical and physical addresses have a finite range, which is determined by the
number of bits used to represent them.

What is Memory Management Unit ?


The physical hardware of a computer that manages its virtual memory and caching
functions is called the memory management unit (MMU). The MMU is sometimes
housed in a separate Integrated Chip (IC), but it is typically found inside the central
processing unit (CPU) of the computer. The MMU receives all inputs for data requests
and decides whether to retrieve the data from ROM or RAM storage.
Difference Between Logical address and Physical Address
Parameter LOGICAL ADDRESS PHYSICAL ADDRESS

Basic generated by CPU location in a memory unit

Logical Address Space is set of all Physical Address is set of all physical
Address
logical addresses generated by addresses mapped to the
Space
CPU in reference to a program. corresponding logical addresses.

User can view the logical address of User can never view physical
Visibility
a program. address of program.

Generation generated by the CPU Computed by MMU

The user can use the logical


The user can indirectly access
Access address to access the physical
physical address but not directly.
address.

Editable Logical address can be change. Physical address will not change.

Also called virtual address. real address.

What is Swapping in the Operating System?


Swapping in an operating system is a process that moves data or programs between
the computer’s main memory (RAM) and a secondary storage (usually a hard
disk or SSD). This helps manage the limited space in RAM and allows the system to
run more programs than it could otherwise handle simultaneously.
It’s important to remember that swapping is only used when data isn’t available in
RAM. Although the swapping process degrades system performance, it allows larger
and multiple processes to run concurrently. Because of this, swapping is also known
as memory compaction. The CPU scheduler determines which processes are
swapped in and which are swapped out. Consider a multiprogramming environment
that employs a priority-based scheduling algorithm. When a high-priority process
enters the input queue, a low-priority process is swapped out so the high-priority
process can be loaded and executed. When this process terminates, the low-priority
process is swapped back into memory to continue its execution. The below figure
shows the swapping process in the operating system:
Swapping has been subdivided into two concepts: swap-in and swap-out.
 Swap-out is a technique for moving a process from RAM to the hard disc.
 Swap-in is a method of transferring a program from a hard disc to main memory, or
RAM.
Process of Swapping
 When the RAM is full and a new program needs to run, the operating system
selects a program or data that is currently in RAM but not actively being used.
 The selected data is moved to the secondary storage, making space in RAM for the
new program.
 When the swapped-out program is needed again, it can be swapped back into
RAM, replacing another inactive program or data if necessary.
Real Life Example of Swapping
Imagine you have a disk (RAM) that is too small to hold all your books and papers
(programs). You keep the most important items on the desk and store the rest in a
cabinet (secondary storage). When you need something from the cabinet, you swap it
with something on your desk. This way, you can work with more items than your desk
alone could hold.
Advantages
 If there is low main memory so some processes may has to wait for much long but
by using swapping process do not have to wait long for execution on CPU.
 It utilize the main memory.
 Using only single main memory, multiple process can be run by CPU using swap
partition.
 The concept of virtual memory start from here and it utilize it in better way.
 This concept can be useful in priority based scheduling to optimize the swapping
process.
Disadvantages
 If there is low main memory resource and user is executing too many processes
and suddenly the power of system goes off there might be a scenario where data
get erase of the processes which are took parts in swapping.
 Chances of number of page faults occur
 Low processing performance
Memory Allocation
Main memory usually has two partitions −

 Low Memory − Operating system resides in this memory.


 High Memory − User processes are held in high memory.

Operating system uses the following memory allocation mechanism.

S.N. Memory Allocation & Description

Single-partition allocation
In this type of allocation, relocation-register scheme is used to protect user processes from each
1 other, and from changing operating-system code and data. Relocation register contains value of
smallest physical address whereas limit register contains range of logical addresses. Each
logical address must be less than the limit register.

Multiple-partition allocation
In this type of allocation, main memory is divided into a number of fixed-sized partitions
2 where each partition should contain only one process. When a partition is free, a process is
selected from the input queue and is loaded into the free partition. When the process
terminates, the partition becomes available for another process.

What is Contiguous Memory Management?


Contiguous memory allocation is a memory allocation strategy. As the name implies,
we utilize this technique to assign contiguous blocks of memory to each task. Thus,
whenever a process asks to access the main memory, we allocate a continuous
segment from the empty region to the process based on its size. In this technique,
memory is allotted in a continuous way to the processes. Contiguous Memory
Management has two types:
 Fixed(or Static) Partition
 Variable(or Dynamic) Partitioning

Contiguous Memory Management Techniques


Below are two Contiguous Memory Management Techniques. Lets understand these
in detail.
1. Fixed Partition Scheme
In the fixed partition scheme, memory is divided into fixed number of partitions. Fixed
means number of partitions are fixed in the memory. In the fixed partition, in every
partition only one process will be accommodated. Degree of multi-programming is
restricted by number of partitions in the memory. Maximum size of the process is
restricted by maximum size of the partition. Every partition is associated with the limit
registers.
 Limit Registers: It has two limit:
 Lower Limit: Starting address of the partition.
 Upper Limit: Ending address of the partition.

Internal Fragmentation is found in fixed partition scheme. To overcome the problem of


internal fragmentation, instead of fixed partition scheme, variable partition scheme is
used.
Disadvantages Fix partition scheme
 Maximum process size <= Maximum partition size.
 The degree of multiprogramming is directly proportional to the number of partitions.
 Internal fragmentation which is discussed above is present.
 If a process of 19kb wants to allocate and we have free space which is not
continuous we are not able to allocate the space.
2. Variable Partition Scheme
In the variable partition scheme, initially memory will be single continuous free block.
Whenever the request by the process arrives, accordingly partition will be made in the
memory. If the smaller processes keep on coming then the larger partitions will be
made into smaller partitions.
 In variable partition schema initially, the memory will be full contiguous free block
 Memory divided into partitions according to the process size where process size will
vary.
 One partition is allocated to each active partition.
External Fragmentation is found in
variable partition scheme. To overcome the problem of external fragmentation,
compaction technique is used or non-contiguous memory management techniques are
used.
Solution of External Fragmentation
1. Compaction
Moving all the processes toward the top or towards the bottom to make free available
memory in a single continuous place is called compaction. Compaction is undesirable
to implement because it interrupts all the running processes in the memory.
Disadvantage of Compaction
 Page fault can occur.
 It consumes CPU time (overhead).
2. Non-contiguous memory allocation
1. Physical address space: Main memory (physical memory) is divided into blocks of
the same size called frames. frame size is defined by the operating system by
comparing it with the size of the process.
2. Logical Address space: Logical memory is divided into blocks of the same size
called process pages. page size is defined by hardware system and these pages
are stored in the main memory during the process in non-contiguous frames.
Advantages of Variable Partition Scheme
 Portion size = process size
 There is no internal fragmentation (which is the drawback of fixed partition
schema).
 Degree of multiprogramming varies and is directly proportional to a number of
processes.
Disadvantage Variable Partition Scheme
 External fragmentation is still there.
Advantages of Contiguous Memory Management
 It’s simple to monitor how many memory blocks are still available for use, which
determines how many more processes can be allocated RAM.
 Considering that the complete file can be read from the disc in a single session,
contiguous memory allocation offers good read performance.
 Contiguous allocation is simple to set up and functions well.
Disadvantages of Contiguous Memory Management
 Fragmentation is not a problem. Since new files can be written to the disk after
older ones.
 To select the appropriate hole size while creating a new file, it needs know its final
size.
 The extra space in the holes would need to be reduced or used once the disk is full.

You might also like