0% found this document useful (0 votes)
18 views15 pages

Unit 3

operating system unit-3 ppt

Uploaded by

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

Unit 3

operating system unit-3 ppt

Uploaded by

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

21AD201-OPERATING

SYSTEM PRINCIPLES

1
UNIT-3

MEMORY MANAGEMENT

2
Memory Management
• Process isolation
• Automatic allocation and management
• Support of modular programming
• Protection and access control
• Long-term storage

3
Swapping
– Swapping is a memory management technique used by
operating systems to temporarily remove pages or portions
of a process's working memory from physical memory and
move them to secondary storage, such as a hard disk or
solid-state drive (SSD).
– This frees up space in physical memory, which can be used
to load other processes or pages.
– It involves several steps, including selecting pages to swap,
writing pages to disk, updating page tables, reading pages
from disk, and updating page tables.
– Swapping can cause performance issues, but is necessary for
managing memory and allowing multiple processes to share
a limited amount of physical memory.
4
Contiguous Memory Allocation
– Contiguous memory allocation is a memory management
technique used by operating systems to allocate memory to
processes.
– It is used primarily in systems with a single memory space,
where each process requires access to the entire memory
space.
– Advantages of contiguous memory allocation include being
easy to implement and efficient in terms of memory usage,
but it can lead to fragmentation of memory.

5
Paging
– Paging is a technique that allows the operating system to allocate
memory (logical) to a process in small fixed-size chunks called
"pages".
– Each page is a contiguous block of memory (if in physical
memory referred as frame) that can be swapped between the RAM
and the hard disk independently of other pages.
– This allows the operating system to efficiently manage memory
and swap out pages that are not currently being used to free up
space in the RAM for other processes.
– When a program references a logical address, the paging system
translates it to a physical address by looking up the corresponding
entry in the page table.
– If the page is not currently in the RAM, a page fault occurs, and
the operating system retrieves the page from the hard disk and
loads it into a free frame in the RAM.
– The page table is then updated to reflect the new location of the
6
page.
Page Table
– A page table is a data structure used by a virtual memory system
to keep track of the mapping between virtual addresses and
physical addresses.
– It is typically stored in main memory and is accessed on every
memory access, so its design can have a significant impact on
system performance.
– The page table is organized as a table of entries, where each entry
corresponds to a page of virtual memory.
– It contains information about the physical page frame that is
currently mapped to the virtual page, as well as other control bits
and metadata.
– The size and structure of the page table can vary depending on
the virtual memory architecture of the system, such as
hierarchical page tables to reduce the size and improve
performance, or hashed page tables to improve lookup speed.
7
Structure of the Page Table
– The main components of a page table entry (PTE) include:
• Page frame number (PFN): This is the physical address of
the page frame that is currently mapped to the virtual
page.
• Valid/Invalid bit: This bit indicates whether the virtual
page is currently mapped to a physical page frame. If the
bit is set to "valid", the page is currently mapped, and the
PFN field contains the physical address of the page frame.
If the bit is set to "invalid", the virtual page is not
currently mapped, and the PFN field is ignored.
• Protection bits: These bits define the access rights for the
page. They determine whether the page is read-only or
read-write, whether it can be executed, and whether it can
be accessed by privileged or unprivileged code.
8
Cont..

• Dirty bit: This bit indicates whether the page has been modified
since it was last written to disk. It is used to optimize page
replacement policies and reduce the number of unnecessary
writes to disk.
• Reference bit: This bit indicates whether the page has been
accessed recently. It is used to optimize page replacement
policies and reduce the number of unnecessary page swaps.
• Page table pointer: In systems that use hierarchical page tables,
the page table pointer field is used to store a pointer to the next
level of the page table.

9
Virtual Memory
– Virtual memory is a computer memory management
technique that allows a computer to use more memory than it
physically has available.
– It is a way of temporarily transferring pages of data from
random access memory (RAM) to disk storage.
– When a program needs to access data or instructions that are
not currently in RAM, the operating system moves the
required data from the hard disk into RAM.
– The operating system then maps the virtual address requested
by the program to a physical address in RAM, allowing the
program to access the requested data or instructions.
– Virtual memory also provides security benefits by isolating
processes and preventing them from accessing each other's
memory spaces.
10
Demand paging
– Demand paging is a memory management technique used
by operating systems to optimize the use of physical
memory.
– It works by dividing a program into pages, which are the
smallest unit of memory that can be loaded into physical
memory.
– When a program needs to access a page of memory that is
not currently in physical memory, the operating system
will load that page into memory from disk storage.
– This process is known as a page fault and can significantly
reduce the amount of physical memory required to run a
program, but it can also introduce performance overhead.
11
Copy-on-write
– Copy-on-write (COW) is a technique used in computer
programming and operating systems to optimize memory usage
and improve performance.
– When a process requests to make a copy of a block of memory,
the operating system sets up a reference to the original block of
memory and marks it as copy-on-write.
– This means that the original block of memory is shared between
the two processes until one of them tries to modify it.
– COW can significantly reduce the memory overhead of creating
new processes or making copies of memory blocks, but it does
add some overhead to the process of modifying memory blocks.

12
Page replacement
– Page replacement is a technique used by computer operating
systems to manage memory when there is not enough physical
memory (RAM) to store all the data needed by running programs.
– When a process requests a memory page that is not present in the
page table, a page fault occurs and the operating system must find
an unused page frame in physical memory to load the requested
page info.
– Page replacement algorithms determine which page frame to evict
when there is no free page frame available in memory.
– There are several common page replacement algorithms, such as
LRU, FIFO, Optimal, and Clock.
– LRU evicts the page that has not been accessed for the longest
time, FIFO evicts the page that was loaded into memory first,
Optimal evicts the page that will not be needed for the longest time
in the future, and Clock evicts the page that will not be needed for
the longest time in the future. 13
Allocation of frames
– The allocation of frames is the process of assigning a certain
amount of memory to a running program or process.
– There are several techniques used to allocate frames, such as
fixed partitioning, dynamic partitioning, paging, and
segmentation.
– Fixed partitioning involves dividing memory into fixed-size
partitions, while dynamic partitioning involves dividing
memory into variable-sized partitions.
– Page allocation involves dividing memory into fixed-size
pages, while segmentation involves dividing memory into
variable-sized segments.

14
Thrashing
– Thrashing is a phenomenon that occurs in computer systems
when the system spends a significant amount of time and
resources continuously swapping pages between physical
memory and virtual memory, without making any real
progress in executing the program.
– It usually occurs when a system is under heavy load and
there is not enough physical memory available to store all the
pages needed by the active processes.
– To prevent thrashing, it is important to ensure that the system
has enough physical memory to handle the workload, use
efficient memory management techniques, and monitor the
system's memory usage and page fault rates.
15

You might also like