0% found this document useful (0 votes)
48 views33 pages

Mms 1

The document discusses memory management techniques. It describes the need for memory management due to limited memory resources. It then covers the basic requirements of memory management including relocation, protection, sharing, logical and physical organization. Next, it discusses memory partitioning techniques including fixed, unequal and dynamic partitioning. Finally, it describes the memory management techniques of paging and segmentation in detail.

Uploaded by

Aashi Negi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
Download as ppt, pdf, or txt
0% found this document useful (0 votes)
48 views33 pages

Mms 1

The document discusses memory management techniques. It describes the need for memory management due to limited memory resources. It then covers the basic requirements of memory management including relocation, protection, sharing, logical and physical organization. Next, it discusses memory partitioning techniques including fixed, unequal and dynamic partitioning. Finally, it describes the memory management techniques of paging and segmentation in detail.

Uploaded by

Aashi Negi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1/ 33

Memory Management

Roadmap
 Basic requirements of Memory
Management
 Memory Partitioning
 Basic blocks of memory management
 Paging
 Segmentation
The need for memory
management
 Memory is cheap today, and getting
cheaper
 But applications are demanding more and
more memory, there is never enough!
 Memory Management, involves swapping
blocks of data from secondary storage.
 Memory I/O is slow compared to a CPU
 The OS must do swapping timely to maximise
the CPU’s efficiency
Memory Management

Memory needs to be allocated to ensure a


reasonable supply of ready processes to
consume available CPU time.
Memory Management
Requirements
 Relocation
 Protection
 Sharing
 Logical organisation
 Physical organisation
Requirements: Relocation
 The programmer does not know where
the program will be placed in memory
when it is executed,
 it may be swapped to disk and return to main
memory at a different location (relocated)
 Memory references must be translated to
the actual physical memory address
Requirements: Protection
 Processes should not be able to reference
memory locations in another process
without permission
 Must be checked at run time that a
process must not go to any other location
in the memory
Requirements: Sharing
 Allow several processes to access the
same portion of memory
 Better to allow each process access to the
same copy of the program rather than
have their own separate copy as it saves
time,money and resources also
Requirements: Logical
Organization
 Memory is organized linearly and used by
user
 Programs are written in modules
 Modules can be written and compiled
independently
 Different degrees of protection given to
modules (read-only, execute-only)
 Share modules among processes
Requirements: Physical
Organization
 Cannot leave the programmer with the
responsibility to manage memory
 Memory available for a program plus its
data may be insufficient
 Programmer does not know how much
space will be available
Partitioning

 Partitioning may be defined as a process


of dividing memory into parts.
 The partitioning is of 2 types:-
 Fixed partitoning
 Dynamic partitioning
Fixed Partitioning
 Equal-size partitions
 In this memory is divided into
equal sizes
 Any process whose size is less
than or equal to the partition size
can be loaded into an available
partition
 The operating system can swap
a process out of a partition
 If none are in a ready or running
state
Fixed Partitioning Problems
 A program may not fit in a partition.
 Main memory use is inefficient.
 Any program, no matter how small, occupies
an entire partition.
 This is results in internal fragmentation.
Solution – Unequal Size
Partitions
 Lessens both problems
 but doesn’t solve completely
 Smaller programs can be placed in
smaller partitions, reducing internal
fragmentation
Fixed Partitioning
Remaining Problems with
Fixed Partitions
 The number of active processes is limited
by the system
 i.e limited by the pre-determined number of
partitions
 A large number of very small process will
not use the space efficiently
 In either fixed or variable length partition
methods
Dynamic Partitioning
 Partitions are of variable length and
number
 Process is allocated exactly as much
memory as required
Dynamic Partitioning (cont)
 External Fragmentation
 Memory external to all
processes is fragmented
 Can resolve using
compaction
 OS moves processes so that
they are contiguous
 Time consuming and wastes
CPU time
Dynamic Partitioning (cont)
 Operating system must decide which
free block to allocate to a process
 Best-fit algorithm
 Chooses the block that is closest in size to the
request
 Since smallest block is found for process, the
smallest amount of fragmentation is left
Dynamic Partitioning (cont)
 First-fit algorithm
 Scans memory form the beginning and
chooses the first available block that is large
enough
 Fastest
 May have many process loaded in the front
end of memory that must be searched over
when trying to find a free block
Dynamic Partitioning (cont)
 Worst-fit
 More often allocate a block of largest block of
memory
 It wastes memory
Memory Management
Memory Management Terms
Terms
Term Description
Frame Fixed-length block of main
memory.
Page Fixed-length block of data in
secondary memory (e.g. on disk).
Segment Variable-length block of data
that resides in secondary
memory.
Paging
 Partition memory into small equal fixed-
size chunks and divide each process into
the same size chunks
 The chunks of a process are called pages
 The chunks of memory are called frames
Paging
 Operating system maintains a page table
for each process
 Contains the frame location for each page in
the process
 Memory address consist of a page number
and offset within the page
Processes and Frames
A.0
A.1
A.2
A.3
D.0
B.0
D.1
B.1
D.2
B.2
C.0
C.1
C.2
C.3
D.3
D.4
Page Table
Segmentation
 A segment can be defined as a logical grouping of
instructions, such as a subroutine, array, or a data area.

 A program is a collection of segments.

 Segmentation is a technique for managing these


segments.

 Divide a process into unequal size blocks called


segments.
Segmentation(cont)
Segmentation(cont)
 A program can be subdivided into
segments
 Segments may vary in length
 There is a maximum segment length
 Addressing consist of two parts
 a segment number and
 an offset
 Segmentation is similar to dynamic
partitioning
Segmentation(cont)
Paging vs Segmentation
• The main memory partitioned into frames or
blocks.
• The logical address space divided into pages
by compiler or MMU.
• Suffers from internal fragmentation or page
break.
• Operating system maintains the page table.
• Does not supports the user view of memory
• Processor uses the page number and
displacement to calculate absolute address.
• Multilevel paging is possible .
Continued
• The main memory partitioned into segments.
• The logical address space divided into segment
specified by the programmer.
• Suffers from external fragmentation.
• Operating system maintains the segment table.
• Supports the user view of memory
• Processor uses the segment number and
displacement to calculate absolute address.
• Multilevel segmentation is possible. But no use.

You might also like