0% found this document useful (0 votes)
0 views

osunit4

The document covers memory management strategies including contiguous memory allocation, paging, and virtual memory management techniques such as demand paging and copy-on-write. It also discusses storage management, specifically focusing on mass storage structures like magnetic disks and HDD scheduling. Key concepts include memory allocation methods, page replacement strategies, and the implications of thrashing in operating systems.

Uploaded by

dharmasasta
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

osunit4

The document covers memory management strategies including contiguous memory allocation, paging, and virtual memory management techniques such as demand paging and copy-on-write. It also discusses storage management, specifically focusing on mass storage structures like magnetic disks and HDD scheduling. Key concepts include memory allocation methods, page replacement strategies, and the implications of thrashing in operating systems.

Uploaded by

dharmasasta
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 60

UNIT-4

Dharmasasta
Memory-Management Strategies:
Introduction, Contiguous memory allocation, Paging, Structure of the Page Table, Swapping.

Virtual Memory Management:


Introduction, Demand paging, Copy-on-write, Page replacement, Allocation of frames,
Thrashing

Storage Management:
Overview of Mass Storage Structure, HDD Scheduling.

Dharmasasta
Dharmasasta
Types of memories in computer

• Primary memory is the computer's main memory and stores


data temporarily. Secondary memory is external memory
and saves data permanently.

Dharmasasta
Contiguous Memory Allocation

• There are two approaches in contiguous Memory allocation:


• 1.Multi programming with fixed size partitions.
• 2.Multi programming with variable size partitions.

Dharmasasta
Multi programming with fixed size
partitions

• The system gets divided into multiple fixed-sized partitions. In this


type of scheme, every partition may consist of exactly one process.
This very process limits the extent at which multiprogramming would
occur, since the total number of partitions decides the total number
of processes.

Dharmasasta
Multi programming with fixed size partitions

Dharmasasta
Multi-programming with
variable size
• Multi-programming with variable partitioning is a contiguous
memory management technique in which the main memory is not
divided into partitions and the process is allocated a chunk of free
memory that is big enough for it to fit.

Dharmasasta
Multi programming with
variable size

Dharmasasta
PAGING
• Paging non contiguous memory allocation
technique.

• Paging is a common virtual memory technique


where memory is divided in to fixed size blocks
called pages.

Dharmasasta
• In paging memory is swapping between primary
memory and secondary memory.

Dharmasasta
Example:
• If the main memory size is 16 KB and Frame size is 1 KB.

• Here, the main memory will be divided into the collection of 16


frames of 1 KB each.

• There are 4 separate processes in the system that is A1, A2, A3,
and A4 of 4 KB each.

• Here, all the processes are divided into pages of 1 KB each so that
operating system can store one page in one frame.

Dharmasasta
Dharmasasta
• At the beginning of the process, all the frames
remain empty so that all the pages of the processes
will get stored in a contiguous way.

• In this example you can see that A2 and A4 are


moved to the waiting state after some time.

• Therefore, eight frames become empty, and so


other pages can be loaded in that empty blocks. The
processes A5 of size 8 pages (8 KB) are waiting in
the ready queue.

Dharmasasta
Dharmasasta
SWAPING

• Swapping is one of the several methods of


memory management.
• 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.

Dharmasasta
Dharmasasta
Dharmasasta
Memory compaction:

• The term memory compaction comes across while studying


swapping.

• When the process swap in and swap out it creates multiple holes into
the memory.

• Well, it is possible to combine all the holes together to create big


memory space. This can be done by moving all the processes
downwards as far as possible. But, doing this will require a lot of CPU
times.

Dharmasasta
Dharmasasta
Virtual Memory

Dharmasasta
Virtual Memory Management

• Virtual memory is a memory management technique where


secondary memory can be used as if it were a part of the
main memory.

• Virtual memory is a common technique used in a


computer's operating system (OS).

Dharmasasta
Virtual Memory is a storage mechanism which offers user an illusion of
having a very big main memory. It is done by treating a part of secondary
memory as the main memory. In Virtual memory, the user can store
processes with a bigger size than the available main memory.

Dharmasasta
Dharmasasta
• Example : Let's assume that an OS requires 300 MB of memory to store all
the running programs. However, there's currently only 50 MB of available
physical memory stored on the RAM.

• The OS will then set up 250 MB of virtual memory and use a program called
the Virtual Memory Manager(VMM) to manage that 250 MB.
• So, in this case, the VMM will create a file on the hard disk that is 250 MB in
size to store extra memory that is required.
• The OS will now proceed to address memory as it considers 300 MB of real
memory stored in the RAM, even if only 50 MB space is available.
• •It is the job of the VMM to manage 300 MB memory even if just 50 MB of
real memory space is available.

Dharmasasta
Demand Paging

• Demand paging is a memory management technique used by


modern operating systems to manage physical memory more
efficiently. It allows the operating system to load only the required
parts of a program into memory at the time of execution, rather than
loading the entire program into memory at once.
• Demand Paging System loads pages only on demand, not in demand.

Dharmasasta
1.Book represents the entire
program.
2.pages are parts of the program
called“pages”.
3.This concept says that we
should not load any pages into the
main memory until we need them,
or keep all pages in secondary
memory until we need them.
Dharmasasta
Dharmasasta
Dharmasasta
Benefits of the Demand Paging:
1.Efficient use of physical memory.
2.Support for larger programs.
3.Faster program start.
4.Reduce memory usage.

Drawbacks of the Demand Paging:


1.Page Fault Overload.
2. Degraded performance.
3. Degraded performance.
4.Fragmentation.
5.Complexity

Dharmasasta
we want to run a process P which has four pages P0, P1, P2, and P3.
Currently, in the page table, we have pages P1 and P3.

Dharmasasta
COPY ON WRITE

Dharmasasta
• Copy on write allows parent and child processes initially to share same
pages.

• Shared pages marked as the copy on write pages.

Dharmasasta
Suppose, there is a process P that creates a
new process Q and then process P modifies
page3.
The below figures shows what happens
before and after process P modifies page 3.

Dharmasasta
Advantages of Copy on Write:
1. Reduced memory usage:
By allowing processes to share memory pages, the operating
system can reduce the amount of physical memory needed to
support multiple processes.

2. Faster process creation time:


• Because the Copy on Write mechanism allows new processes
to share memory pages with existing processes, the time
needed to create a new process is reduced.

Dharmasasta
Page Replacement

Dharmasasta
• Page replacement is needed in the
operating systems that use virtual
memory using Demand Paging. As we
know in Demand paging, only a set of
pages of a process is loaded into the
memory.

• When a page that is residing in virtual


memory is requested by a process for
its execution, the Operating System
needs to decide which page will be
replaced by this requested page.
Dharmasasta
• Common Page Replacement Techniques
• First In First Out (FIFO)
• Optimal Page replacement
• Least Recently Used (LRU)
• Most Recently Used (MRU)

Dharmasasta
First In First Out (FIFO):

• This is the simplest page replacement algorithm.


In this algorithm, the operating system keeps
track of all pages in the memory in a queue, the
oldest page is in the front of the queue.

• When a page needs to be replaced page in the


front of the queue is selected for removal.

Dharmasasta
Dharmasasta
ALLOCATION OF FRAMES

Dharmasasta
• The main memory of the operating system is divided
into various frames.

• The process is stored in these frames, and once the


process is saved as a frame, the CPU may run it.

• The OS has to allocate a sufficient number of frames


for each process and to do so, the OS uses various
algorithms.

Dharmasasta
Dharmasasta
Frame allocation algorithms :
The two algorithms commonly used to allocate frames to
a process are:

1.Equal allocation.
2.Proportional allocation:
3.Priority Frame Allocation:

Dharmasasta
Equal Frame Allocation:
• Equal Frame Allocation is the simplest method where each process is given
an equal share of frames.
• For instance, if there are 30 frames and 7 processes, each process would
receive 4 frames.
• The downside of this approach is its inefficiency in systems with processes
of varying sizes, leading to potential wastage of frames.

Dharmasasta
Propostional allocation:
• Allocate frames according to size of process.

• This method ensures that larger processes get


more frames, improving overall efficiency.

• Advantage:
All the processes share the available frames
according to their needs, rather than equally.

Dharmasasta
Priority Frame Allocation:
• The higher-priority processes are given precedence
by allocating the required number of frames and
allocating the lower-priority frames next.

• This algorithm assigns a priority value to each


process by sorting the process based on the priority
level, and the OS will give the first preference to the
higher-priority process. The process with a higher
priority level is assigned more frames.

Dharmasasta
Thrashing:
• Thrashing in OS is a common phenomenon in computer
systems.

• It occurs when the system spends more time swapping pages


than actually performing useful tasks.

• It is caused by a high number of page faults, which happens


when the system needs to retrieve a page from the disk
because it is not present in memory.

Dharmasasta
Dharmasasta
Mass-Storage Structure:

Dharmasasta
1. Magnetic Disk
• Magnetic disks make up most of the secondary storage in modern
computer systems.
• Each turntable has a flat circular shape like a CD. Common disc diameters
range from 1.8 to 5.25 inches.
• Both sides of the turntable are covered with magnetic material.
• It stores information by magnetically recording it on a disk.

Dharmasasta
Architecture:

• The entire disk is divided into platters.


• Each platter consists of concentric circles called as tracks.
• These tracks are further divided into sectors which are the smallest
divisions in the disk.

Dharmasasta
Dharmasasta
Magnetic Disk (Hard Disk Drive)
Structure)

Dharmasasta
Moving-head disk mechanism.

Dharmasasta
Dharmasasta
A cylinder is formed by
combining the tracks at a given
radius of a disk pack.

Dharmasasta
• There exists a mechanical arm called as Read / Write head.

• It is used to read from and write to the disk.

• Head has to reach at a particular track and then wait for


the rotation of the platter.

• The rotation causes the required sector of the track to


come under the head.

• Each platter has 2 surfaces- top and bottom and both the
surfaces are used to store the data.

• Each surface has its own read / write head.


Dharmasasta
HDD SCHEDULING

Dharmasasta
• Disk scheduling is the process of arranging the
order in which read/write operations are carried out
on a computer's hard disk.
• In modern computer systems, hard disks have a
large storage capacity, and the data is stored in
tracks and sectors.

Dharmasasta

You might also like