Memory and Process Management
click to edit
Main memory and the registers built into the processor itself
the only storage that the CPU can access directly
Gibson
click to edit
Keeping track of which parts of memory
function of memory manager
Deciding which processes and data to move into and out of memory
Allocating and de-allocating memory space as needed
click to edit
access time
Memory Management
memory size
cost per byte
transfer bandwidth
unit of transfer
click to edit
click to edit
Four Level of Memory Hierarchy
click to edit
parts of the processor complex, built either on the processor chip
cache is controlled by the Memory Management Unit (MMU) and is programmer-transparent.
click to edit
Main Memory
sometimes called the primary memory of a computer system
managed by a MMU in cooperation with the operating system
Disk Drives and Tape Units
handled by the OS with limited user intervention
magnetic tape units are off-line memory for use as backup storage
click to edit
Registers and Caches
disk storage is considered the highest level of on-line memory
characterized by five parameters
Memory devices at a lower level are
faster to access
smaller in size,
more expensive per byte
using a smaller unit of transfer
having a higher bandwidth
Segmentation and Paging
Virtual Memory
click to edit
Processes that are not completely in memory
Gibson
Fixed-Partition
Enhance the storage capacity of the working memory without requiring the installation of Random Access Mamory modules
Divide memory
fixed size partitions
possibly of different size
Combines your computer's RAM with temporary space on your hard disk
system initialization time and may not be changed during system operation
region having a fixed size, different regions potentially having different sizes
When RAM runs low , virtual memory moves data from RAM to a space called a paging file
Fixed partitions have fixed size and usually cannot be easily expanded or shrunk
Advantage
Moving data to and from the paging file frees up RAM to complete its work
Easy to implement
Multiprogramming
Simplicity
More RAM your computer has, the faster your program will generally run
Multiple programs can be loaded into memory and executed concurrently
If a lack of RAM is slowing, you might be tempted to increase virtual memory
Computer can read data from RAM quickly than from hard disk , so adding RAM
click to edit
Fixed-Partition Allocation
How Virtual Memory Work
Common part of most operating system on desktop computer
Become common because it provides a big benefit for user at a very low cost
Dynamic Partition
Jazrin
Have like 512/1Gigabytes of RAM available for the CPU to use
RAM is not enough to run all of the program that most users expect to run at once
Fixed-Partition Memory Management divides the available space into
fixed-length partitions each of which holds one program
Abstract View Of Memory Allocation
Dynamic partitions can change size by themselves when
they need it.
Example: if you load the operating system ,an 3D game into RAM simultaneously,512 Gigabyte is not enough to hold it all
Filed up the available RAM and your computer can not load any more application
Allow the partitions to be variable in size at load time.
Allocate to the process the exact amount of memory it
requires.
Close another application to load a new one
Frees up space in RAM to load the new application
Process
When it is not the case, operating system has to constantly swap information back and forth between RAM and hard disk . it can make your computer feel incredibly slow
loaded into consecutive areas until the
memory is filled / more likely, the remaining space is
too small to accommodate another process.
transient
area
treated as a pool of unstructured free space
Because a program gets only the space it needs,
relatively little is wasted.
Area of the hard disk that stores the RAM image is called a page file .It hold pages of RAM on the hard disk and the operating systems moves data back and forth between the page file and RAM
Segmentation
Another memory management approach , segmentation , is similar to a partition of varied size
Advantages
Jobs are given only as much memory as they request.
Program is divided into several segment , each similar to a partition of varied size
Segmentation, is usually visible , which is actually based on the programmers 'logical' view of programs
Still, contiguous blocks are needed
Disadvantages
Suffer external fragmentation.
John tsai
Paging
The ways in which the operating system can store and retrieve data
From secondary storage for use in main memory .
Break the main memory into fixed-sized blocks called frames
Break the program or process image into blocks of the same size called pages
Jazrin
Jazrin
Routines
A section of a program that performs a particular task.
term routine
synonymous with procedure, function,
and subroutine.
Operating System
A collection of software routines.
Two types of routines
Resident routine
Term overlay
Permanent in memory.
A computer does not have enough memory
to hold all the programs you use.
Also known as swapping
A process can be swapped temporarily out of memory to a backing store, and then brought back into memory for continued execution
Major part(swap time)
transfer time; total transfer time is directly proportional to the amount of memory swapped
click to edit
click to edit
click to edit
ARIF
Describe memory management strategies:
Fetch strategies
click to edit
Fetch
Placement
Replacement
• When to bring data into primary memory
Where in primary memory should data be placed
Which page should be replaced, if primary memory is full.
1.Demand Paging
2.Anticipatory Paging
Placement Strategy
click to edit
Memory allocation is the process of assigning blocks of memory on request.
Typically the allocator receives memory from the operating system in a small number of large blocks that it must divide up to satisfy the requests for smaller blocks.
It must also make any returned blocks available for reuse.
There are many common ways to perform this, with different strengths and weaknesses.
- Best Fit Strategy
click to edit
The memory manager places a process in the smallest memory in which it will fit.
This strategy produces the smallest leftover hole.
Entire list of holes is to be searched.
Search of entire list can be avoided by keeping the list of holes sorted by size.
- Worst Fit Strategy
Example
Suppose a process request 12KB of memory and the memory manager currently has a list of unallocated blocks of 6KB, 14KB, 19KB,11 KB, and 13KB blocks. The best fit strategy will allocate the 13 KB block to the process
Procedure
- Avoid negative reminder
- Scan and compare
- Allow extra space
click to edit
Allocate the largest hole.
In contrast, this strategy aims to produce the largest leftover hole, which may be big enough to hold another process.
For example
If the list of unallocated blocks consists of 6KB, 14KB, 19KB, 11 KB, and 13KB blocks and a process request a 12KB block, Then the worst fit will split the 19KB block into a 12KB block to allocate to the process, leaving a 7KB block for future use.
click to edit
- Scan and compare
- Avoid negative remainder
- Allow MORE extra space
- First Fit Strategy
click to edit
Allocate the first hole that is big enough.
Searching may start either at the beginning of the set of holes or where the previous first-fit search ended.
Stop searching as soon as first hole large enough to hold the process is found.
The first fit approach tends to fragment the blocks near the beginning of the list without considering blocks further down the list.
Example
If the list of unallocated blocks consists of 6KB, 14KB, 19KB, 11 KB, and 13KB blocks and a process request a 12KB block, First Fit will allocate the 14KB block to the process.
click to edit
1.Avoid negative remainder
- Allow extra space
Replacement Strategies
click to edit
When a process generates a page fault, the memory manager must locate referenced page in secondary storage, load it into page frame in main memory and update corresponding page table entry.
If no frame is free, we find one that is not currently being used and free it.
We can free a frame by writing its contents to swap space and changing the page table (and all other tables) to indicate that the page is no longer in memory
click to edit
Least-Recently-Used (LRU)
Least-Frequently-Used (LFU)
First-In-First-Out (FIFO)
Not-Used-Recently (NUR)
Placement Strategy Approach
A number of approach that are used to allocate space to the processes that are competing for memory
click to edit
Worst Fit
First Fit
Best Fit
Modified version (founded on many systems)
Example
UNIX
Linux
Windows
Certain programs
can be marked as being memory resident, which means that the operating system is not permitted to swap them out to a storage device; they will always remain in memory
The programs and data
used most frequently are the ones that
should be memory resident
Example
calendars and
calculators
that you want to be able to access immediately.
Another term
RAM resident.
DOS systems
memory-resident programs are called pop-up
utilities or TSRs (terminate and stay resident).
Meaning
a module that, once loaded into main memory, is
expected to remain in memory for a short time.
commonly used instead, and refer to a program
module that is brought to memory
Program modules
written to allow different modules to share
the same memory region and the main program itself
responsible of exchanging modules between disk and memory as
necessary
The operating system ( Resident & Transient Routines )
Transient routine
occupies low
memory.
The remining memory
Transient area
Comparison
Program is bought into memory for execution as pages
Takes the pages from main memory during execution
When the pages required is not in main memory , the operating systems fetches the required page from hard disk into main memory and moves the other page
This process is reduced as Paging
When process is to be executed , its pages are loaded into any available frames
Paging leads to problems of internal Fragmentation
When a page of smaller size than the size of frame is placed in a large size frame,it leads to unused memory space within a frame
This wastage of unused memory is called internal Fragmentation
Paging Advantage
Allow the physical address space of a process to be noncontiguous
Paging Disadvantage
Internal fragmentation occur
Segmentation and paging
Address are divided into a segment number ,a page number within that segment ,and a displacement within that page
After control unit the relative address, dynamic address Translation begins
Program segment table is searched for you the segment number , which yields the address of the segments page table
It wiil searched for the page base address, which is added to the displacement to get an absolute address
Summarize
So, this topic we can learn the what is Virtual memory, and how virtual memory work.This two topic have the relationship with RAM , Example virtual memory can read data from RAM more fast than a hard disk. And we also learn the Segmentation and paging . Example to paging , when a page of 3 MB, is placed in a frame of 5 MB,2 MB of memory in the frame is wasted.