MITC101

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 42

PRESENTION

IN

OPERATING SYSTEM
MEMORY MANAGEMENT
RAPCHEL ESTRELLA

CARL ANGELO FERNANDEZ


SUBMITTED TO: DOC. JAN CARL ARROYO
OPERATING SYSTEM
MEMORY
MANAGEMENT
Memory management is a critical component of
operating systems, responsible for handling computer
memory resources efficiently.
Memory Hierarchy
The memory hierarchy refers to the arrangement of different types of
memory in a computer system, each with varying levels of speed, capacity,
and cost. This hierarchy is designed to provide a balance between
performance and cost-effectiveness. The main components of the memory
hierarchy include
Address Spaces

• In the context of computer systems and operating systems,


an address space refers to the range of valid addresses that
can be used to identify memory locations in a given
system. Each process in a computer system typically has
its own address space, providing a logical view of memory
that is independent of the actual physical memory layout
The logical address space refers to the range of memory
addresses that a program can use or generate during its execution.

Address Binding

1.Compile time-Particular space program will be loaded until the time program
will be residing

2.Load time- Relocatable addressing format.

3.Execution
Memory Allocation
• Is the process of setting aside sections of memory in a program to be used
to store variables, and instances of structures and classes
Static Memory
• Memory allocated during compile time is called static memory.
• The memory allocated is fixed and cannot be increased or decrease during
run time.
Int main ()
{ int arr [5] =
{ 1,2,3,4,5};
}
Dynamic Memory

• Dynamic memory refers to memory allocation and deallocation during the


execution of a program

• The process of allocating memory at the time of execution is called


dynamic memory allocation.
Heap

• Is the segment of memory where dynamic memory allocation takes


place.
• Unlike stack where memory is allocated or deallocated in a defined
order heap is an area of memory where memory is allocated or
deallocated without any order or randomly.

• There are certain built-in functions that can help in allocating or


deallocating some memory space at run time
Pointers
• Play an important role in dynamic memory allocation

• Allocated memory can only be accessed through pointer.


Dynamic memory allocation built in function
• Malloc: Memory allocation creates a single blocks of memory of a
specific size
• Calloc: (contiguous allocation) Assigns multiple blocks of memory to a
single variable.

• Realloc: Changes the size of a previously reserved storage block.


• Free:
Memory Mapping
• Memory mapping is a technique used in computer systems to map files or
devices into the memory address space of a program. It allows a process,
including applications and the operating system itself, to interact with files
as if they were portions of the program's memory
How Cache Memory Work
Memory Management Techniques
• The following are the three key memory management techniques used by
an operating system:

1. Swapping
2. Paging
3. Segmentation
Swapping

• When a process is executed, it must have resided in memory. Swapping is a process of swapping a
process temporarily into a secondary memory from the main memory, which is fast compared to
secondary memory. A swapping allows more processes to be run and can be fit into memory at one
time.
• The main part of swapping is transferred time and the total time is directly proportional to the amount
of memory swapped. Swapping is also known as roll-out, or roll in because if a higher priority process
arrives and wants service, the memory manager can swap out the lower priority process and then load
and execute the higher priority process. After finishing higher priority work, the lower priority process
swapped back in memory and continued to the execution process. The swapping technique is useful
when larger program is to be executed or some operations have to performed on a large file.
Paging

• Paging is a technique in which the main memory of computer system is organized in


the form of equal sized blocks called pages. In this technique, the address of occupied
pages of physical memory are stored in a table, which is known as page table.
• Paging enables the operating system to obtain data from the physical memory
location without specifying length memory address in the instruction. In this technique,
the virtual address is used to map the physical address of the data. The length of virtual
address is specified in the instruction and is smaller than physical address of the data. It
consists of two different numbers, first number is the address of page called virtual
page in the page table and the second number is the offset value of the actual data in
the page.
Paging in Operating System – Memory Management
• 1. In computer operating systems, paging is a memory management scheme
by which a computer stores and retrieves data from secondary storage for
use in main memory.
• 2. In this scheme, the operating system retrieves data from secondary
storage in same-size blocks called pages.
• Paging is an important part of virtual memory implementations in modern
operating systems, using secondary storage to let programs exceed the size
of available physical memory.
• 3. virtual memory space is divided into equal size pages
• 4. physical memory is divided into equal size frames
• 5. Page Size = Frame Size (frame size is always equals to the page size)
What is the effect of Paging and use of
Paging in an Operating system?
• Paging is a memory management technique that is used to retrieve
processes from secondary storage to main memory.
• Paging helps in improving the performance of the system by improving the
utilization of the memory and accessing the available memory present
there.
Types of Segmentation in Operating Systems

• 1. Simple Segmentation in OS is a memory management method employed in


computer programming. It divides a program's processes into several segments,
which are smaller program components. These segments are placed in memory
during the program's execution. However, unlike conventional Segmentation,
where all segments are located next to each other in memory, Simple
Segmentation scatters these segments throughout memory, potentially placing
them in different locations. This approach can be advantageous for optimizing
memory utilization and enhancing overall system performance.
2. Virtual Memory Segmentation in OS is a memory management
technique used in computer systems. It divides processes into multiple
segments, with the number of segments represented by 'n'. Unlike some
other methods, not all segments are divided simultaneously. Whether or not
virtual memory segmentation occurs during a program's runtime depends on
the specific circumstances and system requirements.
What is a Segment Table?

• In a segmented memory architecture, a segment table maintains track of


different chunks of memory a program uses. Each segment table entry
corresponds to a separate program segment and details the segment's beginning
address and size.

• The CPU uses segment tables in combination with segment registers. The CPU
utilizes the segment entry value to search for the relevant record in the segment
table when a program reads memory to identify the address to begin and the
dimensions of the section being addressed.
Memory Fragmentation

• Fragmentation is an unwanted problem in the operating system in which the processes are
loaded and unloaded from memory, and free memory space is fragmented. Processes can't
be assigned to memory blocks due to their small size, and the memory blocks stay unused.

• Contiguous memory allocation allocates space to processes whenever the processes enter
RAM. These RAM spaces are divided either by fixed partitioning or by dynamic
partitioning. As the process is loaded and unloaded from memory, these areas are
fragmented into small pieces of memory that cannot be allocated to coming processes.
Causes of Fragmentation
• User processes are loaded and unloaded from the main memory, and
processes are kept in memory blocks in the main memory. Many spaces
remain after process loading and swapping that another process cannot
load due to their size. Main memory is available, but its space is
insufficient to load another process because of the dynamical allocation of
main memory processes.
Types of Fragmentation

There are mainly two types of fragmentation in the operating system. These
are as follows:

1. Internal Fragmentation
2. External Fragmentation
• Internal Fragmentation

When a process is allocated to a memory block, and if the process is smaller


than the amount of memory requested, a free space is created in the given
memory block. Due to this, the free space of the memory block is unused,
which causes internal fragmentation.
How to avoid internal fragmentation?

• The problem of internal fragmentation may arise due to the fixed sizes of
the memory blocks. It may be solved by assigning space to the process via
dynamic partitioning. Dynamic partitioning allocates only the amount of
space requested by the process. As a result, there is no internal
fragmentation.
• External Fragmentation

External fragmentation happens when a dynamic memory allocation


method allocates some memory but leaves a small amount of memory
unusable. The quantity of available memory is substantially reduced if there
is too much external fragmentation. There is enough memory space to
complete a request, but it is not contiguous. It's known
as external fragmentation.
THANK YOU.

You might also like