B.tech 3 - Coa - Unit-4 Notes PDF
B.tech 3 - Coa - Unit-4 Notes PDF
S.
No. Associative Memory Cache Memory
Its basic characteristic is its logic Its basic characteristic is its fast
5
circuit for matching its content. access.
Demand Paging
• If the CPU tries to refer to a page that is currently not available in the main
memory, it generates an interrupt indicating a memory access fault.
• The OS puts the interrupted process in a blocking state. For the execution to
proceed the OS must bring the required page into the memory.
• The OS will search for the required page in the logical address space.
• The required page will be brought from logical address space to physical
address space. The page replacement algorithms are used for the
decision-making of replacing the page in physical address space.
• The page table will be updated accordingly.
• The signal will be sent to the CPU to continue the program execution and it
will place the process back into the ready state.
Hence whenever a page fault occurs these steps are followed by the operating
system and the required page is brought into memory.
What is Page Fault Service Time?
The time taken to service the page fault is called page fault service time. The
page fault service time includes the time taken to perform all the above six
steps.
Let Main memory access time is: m
Page fault service time is: s
Page fault rate is : p
Then, Effective memory access time = (p*s) + (1-p)*m
Segmentation
Segmentation divides virtual memory into segments of different sizes.
Segments that aren’t currently needed can be moved to the hard drive. The
system uses a segment table to keep track of each segment’s status, including
whether it’s in memory, if it’s been modified, and its physical address.
Segments are mapped into a process’s address space only when needed.
Combining Paging and Segmentation
Sometimes, both paging and segmentation are used together. In this case,
memory is divided into pages, and segments are made up of multiple pages.
The virtual address includes both a segment number and a page number.
Data Indirect (via paging and Direct (CPU can access data
Access swapping) directly)
What is Swapping?
Swapping is a process out means removing all of its pages from memory, or
marking them so that they will be removed by the normal page replacement
process. Suspending a process ensures that it is not runnable while it is
swapped out. At some later time, the system swaps back the process from the
secondary storage to the main memory. When a process is busy swapping
pages in and out then this situation is called thrashing.
Swappinghierar
What is Thrashing?
At any given time, only a few pages of any process are in the main memory,
and therefore more processes can be maintained in memory. Furthermore, time
is saved because unused pages are not swapped in and out of memory.
However, the OS must be clever about how it manages this scheme. In the
steady state practically, all of the main memory will be occupied with process
pages, so that the processor and OS have direct access to as many processes as
possible. Thus when the OS brings one page in, it must throw another out. If it
throws out a page just before it is used, then it will just have to get that page
again almost immediately. Too much of this leads to a condition called
Thrashing. The system spends most of its time swapping pages rather than
executing instructions. So a good page replacement algorithm is required.
In the given diagram, the initial degree of multiprogramming up to some extent
of point(lambda), the CPU utilization is very high and the system resources are
utilized 100%. But if we further increase the degree of multiprogramming the
CPU utilization will drastically fall down and the system will spend more time
only on the page replacement and the time taken to complete the execution of
the process will increase. This situation in the system is called thrashing.
Causes of Thrashing
Thrashing occurs in a computer system when the CPU spends more time
swapping pages in and out of memory than executing actual processes. This
happens when there is insufficient physical memory, causing frequent page
faults and excessive paging activity. Thrashing reduces system performance
and makes processes run very slowly. There are many cause of thrashing as
discussed below.
1. High Degree of Multiprogramming: If the number of processes keeps on
increasing in the memory then the number of frames allocated to each process
will be decreased. So, fewer frames will be available for each process. Due to
this, a page fault will occur more frequently and more CPU time will be wasted
in just swapping in and out of pages and the utilization will keep on
decreasing.
For example:
Let free frames = 400
Case 1: Number of processes = 100
Then, each process will get 4 frames.
Case 2: Number of processes = 400
Each process will get 1 frame.
Case 2 is a condition of thrashing, as the number of processes is increased,
frames per process are decreased. Hence CPU time will be consumed just by
swapping pages.
2. Lacks of Frames: If a process has fewer frames then fewer pages of that
process will be able to reside in memory and hence more frequent swapping in
and out will be required. This may lead to thrashing. Hence a sufficient amount
of frames must be allocated to each process in order to prevent thrashing.
Recovery of Thrashing
Do not allow the system to go into thrashing by instructing the long-term
scheduler not to bring the processes into memory after the threshold.
If the system is already thrashing then instruct the mid-term scheduler to
suspend some of the processes so that we can recover the system from
thrashing.
Performance in Virtual Memory
• Let p be the page fault rate( 0 <= p <= 1).
• if p = 0 no page faults
• if p =1, every reference is a fault.
Effective access time (EAT) = (1-p)* Memory Access Time + p * Page fault
time.
Page fault time = page fault overhead + swap out + swap in +restart overhead
The performance of a virtual memory management system depends on the total
number of page faults, which depend on “paging policies” and “frame
allocation“
Frame Allocation
A number of frames allocated to each process in either static or dynamic.
• Static Allocation: The number of frame allocations to a process is fixed.
• Dynamic Allocation: The number of frames allocated to a process changes.
Paging Policies
• Fetch Policy: It decides when a page should be loaded into memory.
• Replacement Policy: It decides which page in memory should be replaced.
• Placement Policy: It decides where in memory should a page be loaded.
What are the Applications of Virtual memory?
Virtual memory has the following important characteristics that increase the
capabilities of the computer system. The following are five significant
characteristics of Lean.
• Increased Effective Memory: One major practical application of virtual
memory is, virtual memory enables a computer to have more memory
than the physical memory using the disk space. This allows for the
running of larger applications and numerous programs at one time while
not necessarily needing an equivalent amount of DRAM.
• Memory Isolation: Virtual memory allocates a unique address space to each
process and that also plays a role in process segmentation. Such
separation increases safety and reliability based on the fact that one
process cannot interact with and or modify another’s memory space
through a mistake, or even a deliberate act of vandalism.
• Efficient Memory Management: Virtual memory also helps in better
utilization of the physical memories through methods that include
paging and segmentation. It can transfer some of the memory pages that
are not frequently used to disk allowing RAM to be used by active
processes when required in a way that assists in efficient use of memory
as well as system performance.
• Simplified Program Development: For case of programmers, they don’t
have to consider physical memory available in a system in case of
having virtual memory. They can program ‘as if’ there is one big block
of memory and this makes the programming easier and more efficient in
delivering more complex applications.
How to Manage Virtual Memory?
Here are 5 key points on how to manage virtual memory:
1. Adjust the Page File Size
• Automatic Management: All contemporary operating systems including
Windows contain the auto-configuration option for the size of the
empirical page file. But depending on the size of the RAM, they are set
automatically, although the user can manually adjust the page file size if
required.
• Manual Configuration: For tuned up users, the setting of the custom size
can sometimes boost up the performance of the system. The initial size
is usually advised to be set to the minimum value of 1. To set the size of
the swap space equal to 5 times the amount of physical RAM and the
maximum size 3 times the physical RAM.
2. Place the Page File on a Fast Drive
• SSD Placement: If this is feasible, the page file should be stored in the SSD
instead of the HDD as a storage device. It has better read and write
times, and the virtual memory may prove benefecial in an SSD.
• Separate Drive: Regarding systems having multiple drives involved, the
page file needs to be placed on a different drive than the os and that
shall in turn improve its performance.
3. Monitor and Optimize Usage
• Performance Monitoring: Employ the software tools used in monitoring the
performance of the system in tracking the amounts of virtual memory.
High page file usage may signify that there is a lack of physical RAM or
that virtual memory needs a change of settings or addition in physical
RAM.
• Regular Maintenance: Make sure there is no toolbar or other application
running in the background, take time and uninstall all the tool bars to
free virtual memory.
4. Disable Virtual Memory for SSD
• Sufficient RAM: If for instance your system has a big physical memory, for
example 16GB and above then it would be advised to freeze the page
file in order to minimize SSD usage. But it should be done, in my
opinion, carefully and only if the additional signals that one decides to
feed into his applications should not likely use all the available RAM.
5. Optimize System Settings
• System Configuration: Change some general properties of the system
concerning virtual memory efficiency. This also involves enabling
additional control options in Windows such as adjusting additional
system setting option on the operating system, or using other options in
different operating systems such as Linux that provides different tools
and commands to help in adjusting how virtual memory is utilized.
• Regular Updates: Ensure that your drivers are run in their newest version
because new releases contain some enhancements and issues regarding
memory management.
What are the Benifits of Using Virtual Memory?
• Many processes maintained in the main memory.
• A process larger than the main memory can be executed because of demand
paging. The OS itself loads pages of a process in the main memory as
required.
• It allows greater multiprogramming levels by using less of the available
(primary) memory for each process.
• It has twice the capacity for addresses as main memory.
• It makes it possible to run more applications at once.
• Users are spared from having to add memory modules when RAM space
runs out, and applications are liberated from shared memory
management.
• When only a portion of a program is required for execution, speed has
increased.
• Memory isolation has increased security.
• It makes it possible for several larger applications to run at once.
• Memory allocation is comparatively cheap.
• It doesn’t require outside fragmentation.
• It is efficient to manage logical partition workloads using the CPU.
• Automatic data movement is possible.
What are the Limitation of Virtual Memory?
• It can slow down the system performance, as data needs to be constantly
transferred between the physical memory and the hard disk.
• It can increase the risk of data loss or corruption, as data can be lost if the
hard disk fails or if there is a power outage while data is being
transferred to or from the hard disk.
It can increase the complexity of the memory management system, as the
operating system needs to manage both physical and virtual memory.
Secondary Memory
In a computer, memory refers to the physical devices that are used to store
programs or data on a temporary or permanent basis. It is a group of registers.
Memory are of two types (i) primary memory, (ii) secondary memory. Primary
memory is made up of semiconductors, It is also divided into two types, Read-
Only Memory (ROM) and Random Access Memory (RAM). Secondary
memory is a physical device for the permanent storage of programs and
data(Hard disk, Compact disc, Flash drive, etc.).
Secondary memory is a type of computer memory that is used to store data and
programs that can be accessed or retrieved even after the computer is turned
off. Unlike primary memory, which is volatile and temporary, secondary
memory is non-volatile and can store data and programs for extended periods
of time.
• Some examples of secondary memory include hard disk drives (HDDs),
solid-state drives (SSDs), optical discs (such as CDs and DVDs), and
flash memory (such as USB drives and memory cards). These storage
devices provide a much larger capacity than primary memory and are
typically used to store large amounts of data, such as operating systems,
application programs, media files, and other types of digital content.
• Secondary memory can be classified into two types: magnetic storage and
solid-state storage. Magnetic storage devices, such as hard disk drives
and magnetic tapes, use magnetic fields to store and retrieve data. Solid-
state storage devices, such as solid-state drives and flash memory, use
semiconductor-based memory chips to store data.
• One of the main advantages of secondary memory is its non-volatile nature,
which means that data and programs stored on secondary memory can
be accessed even after the computer is turned off. Additionally,
secondary memory devices provide a large storage capacity, making it
possible to store large amounts of data and programs.
However, there are also some disadvantages to secondary memory, such as
slower access times and lower read/write speeds compared to primary memory.
Additionally, secondary memory devices are often more prone to mechanical
failures and data corruption, which can result in data loss.
Overall, secondary memory plays an important role in modern computing
systems and is essential for storing large amounts of data and programs.
Primary Memory
Primary memory is made up of semiconductors and it is the main memory of
the computer system. It is generally used to store data or information on which
the computer is currently working, so we can say that it is used to store data
temporarily. Data or information is lost when the systems are off. It is also
divided into two types:
(i). Read-Only Memory (ROM)
(ii). Random Access Memory (RAM).
1. Random Access Memory: Primary memory is also called internal memory.
This is the main area in a computer where data, instructions, and information
are stored. Any storage location in this memory can be directly accessed by the
Central Processing Unit. As the CPU can randomly access any storage location
in this memory, it is also called Random Access Memory or RAM. The CPU
can access data from RAM as long as the computer is switched on. As soon as
the power to the computer is switched off, the stored data and instructions
disappear from RAM. Such type of memory is known as volatile memory.
RAM is also called read/write memory.
2. Read-Only Memory: Read-Only Memory (ROM) is a type of primary
memory from which information can only be read. So it is also known as Read-
Only Memory. ROM can be directly accessed by the Central Processing Unit.
But, the data and instructions stored in ROM are retained even when the
computer is switched off OR we can say it holds the data after being switched
off. Such type of memory is known as non-volatile memory.
Secondary Memory
We have read so far, that primary memory is volatile and has limited capacity.
So, it is important to have another form of memory that has a larger storage
capacity and from which data and programs are not lost when the computer is
turned off. Such a type of memory is called secondary memory. In secondary
memory, programs and data are stored. It is also called auxiliary memory. It is
different from primary memory as it is not directly accessible through the CPU
and is non-volatile. Secondary or external storage devices have a much larger
storage capacity and the cost of secondary memory is less as compared to
primary memory.
Use of Secondary memory
Secondary memory is used for different purposes but the main purposes of
using secondary memory are:
• Permanent storage: As we know that primary memory stores data only
when the power supply is on, it loses data when the power is off. So we
need a secondary memory to stores data permanently even if the power
supply is off.
• Large Storage: Secondary memory provides large storage space so that we
can store large data like videos, images, audios, files, etc permanently.
• Portable: Some secondary devices are removable. So, we can easily store or
transfer data from one computer or device to another.
Types of Secondary memory
Secondary memory is of two types:
1. Fixed storage
In secondary memory, a fixed storage is an internal media device that is used to
store data in a computer system. Fixed storage is generally known as fixed disk
drives or hard drives. Generally, the data of the computer system is stored in a
built-in fixed storage device. Fixed storage does not mean that you can not
remove them from the computer system, you can remove the fixed storage
device for repairing, for the upgrade, or for maintenance, etc. with the help of
an expert or engineer.
Types of fixed storage:
Following are the types of fixed storage:
• Internal flash memory (rare)
• SSD (solid-state disk)
• Hard disk drives (HDD)
2. Removable storage
In secondary memory, removable storage is an external media device that is
used to store data in a computer system. Removable storage is generally known
as disks drives or external drives. It is a storage device that can be inserted or
removed from the computer according to our requirements. We can easily
remove them from the computer system while the computer system is running.
Removable storage devices are portable so we can easily transfer data from one
computer to another. Also, removable storage devices provide the fast data
transfer rates associated with storage area networks (SANs).
Types of Removable Storage:
• Optical discs (like CDs, DVDs, Blu-ray discs, etc.)
• Memory cards
• Floppy disks
• Magnetic tapes
• Disk packs
• Paper storage (like punched tapes, punched cards, etc.)
Secondary memory devices
Following are the commonly used secondary memory devices are:
1. Floppy Disk: A floppy disk consists of a magnetic disc in a square plastic
case. It is used to store data and to transfer data from one device to another
device. Floppy disks are available in two sizes (a) Size: 3.5 inches, the Storage
capacity of 1.44 MB (b) Size: 5.25 inches, the Storage capacity of 1.2 MB. To
use a floppy disk, our computer needs to have a floppy disk drive. This storage
device becomes obsolete now and has been replaced by CDs, DVDs, and flash
drives.
2. Compact Disc: A Compact Disc (CD) is a commonly used secondary
storage device. It contains tracks and sectors on its surface. Its shape is circular
and is made up of polycarbonate plastic. The storage capacity of CD is up to
700 MB of data. A CD may also be called a CD-ROM (Compact Disc Read-
Only Memory), in this computers can read the data present in a CD-ROM, but
cannot write new data onto it. For a CD-ROM, we require a CD-ROM. CD is
of two types:
• CD-R (compact disc recordable): Once the data has been written onto it
cannot be erased, it can only be read.
• CD-RW (compact disc rewritable): It is a special type of CD in which data
can be erased and rewritten as many times as we want. It is also called
an erasable CD.
3. Digital Versatile Disc: A Digital Versatile Disc also known as DVD it is
looks just like a CD, but the storage capacity is greater compared to CD, it
stores up to 4.7 GB of data. DVD-ROM drive is needed to use DVD on a
computer. The video files, like movies or video recordings, etc., are generally
stored on DVD and you can run DVD using the DVD player. DVD is of three
types:
• DVD-ROM(Digital Versatile Disc Readonly): In DVD-ROM the
manufacturer writes the data in it and the user can only read that data,
cannot write new data in it. For example movie DVD, movie DVD is
already written by the manufacturer we can only watch the movie but
we cannot write new data into it.
• DVD-R(Digital Versatile Disc Recordable): In DVD-R you can write the
data but only one time. Once the data has been written onto it cannot be
erased, it can only be read.
• DVD-RW(Digital Versatile Disc Rewritable and Erasable): It is a special
type of DVD in which data can be erased and rewritten as many times as
we want. It is also called an erasable DVD.
4. Blu-ray Disc: A Blu-ray disc looks just like a CD or a DVD but it can store
data or information up to 25 GB data. If you want to use a Blu-ray disc, you
need a Blu-ray reader. The name Blu-ray is derived from the technology that is
used to read the disc ‘Blu’ from the blue-violet laser and ‘ray’ from an optical
ray.
5. Hard Disk: A hard disk is a part of a unit called a hard disk drive. It is used
to storing a large amount of data. Hard disks or hard disk drives come in
different storage capacities.(like 256 GB, 500 GB, 1 TB, and 2 TB, etc.). It is
created using the collection of discs known as platters. The platters are placed
one below the other. They are coated with magnetic material. Each platter
consists of a number of invisible circles and each circle having the same centre
called tracks. Hard disk is of two types (i) Internal hard disk (ii) External hard
disk.
6. Flash Drive: A flash drive or pen drive comes in various storage capacities,
such as 1 GB, 2 GB, 4 GB, 8 GB, 16 GB, 32 GB, 64 GB, up to 1 TB. A flash
drive is used to transfer and store data. To use a flash drive, we need to plug it
into a USB port on a computer. As a flash drive is easy to use and compact in
size, Nowadays it is very popular.
7. Solid-state disk: It is also known as SDD. It is a non-volatile storage device
that is used to store and access data. It is faster, does noiseless
operations(because it does not contain any moving parts like the hard disk),
consumes less power, etc. It is a great replacement for standard hard drives in
computers and laptops if the price is low and it is also suitable for tablets,
notebooks, etc because they do not require large storage.
8. SD Card: It is known as a Secure Digital Card. It is generally used in
portable devices like mobile phones, cameras, etc., to store data. It is available
in different sizes like 1 GB, 2 GB, 4 GB, 8 GB, 16 GB, 32 GB, 64 GB, etc. To
view the data stored in the SD card you can remove them from the device and
insert them into a computer with help of a card reader. The data stores in the
SD card is stored in memory chips(present in the SD Card) and it does not
contain any moving parts like the hard disk.