SlideShare a Scribd company logo
1 of 54
Silberschatz, Galvin and Gagne ©20029.1
Chapter 9: Memory Management
Background
Swapping
Contiguous Allocation
Paging
Segmentation
Segmentation with Paging
Silberschatz, Galvin and Gagne ©20029.2
Background
Program must be brought into memory and placed within
a process for it to be run.
Input queue – collection of processes on the disk that are
waiting to be brought into memory to run the program.
User programs go through several steps before being
run.
Silberschatz, Galvin and Gagne ©20029.3
Binding of Instructions and Data to
Memory
Compile time: If memory location known a priori,
absolute code can be generated; must recompile code if
starting location changes.
Load time: Must generate relocatable code if memory
location is not known at compile time.
Execution time: Binding delayed until run time if the
process can be moved during its execution from one
memory segment to another. Need hardware support for
address maps (e.g., base and limit registers).
Address binding of instructions and data to memory addresses can
happen at three different stages.
Silberschatz, Galvin and Gagne ©20029.4
Multistep Processing of a User Program
Silberschatz, Galvin and Gagne ©20029.5
Logical vs. Physical Address Space
The concept of a logical address space that is bound to a
separate physical address space is central to proper
memory management.
Logical address – generated by the CPU; also referred to as
virtual address.
Physical address – address seen by the memory unit.
Logical and physical addresses are the same in compile-
time and load-time address-binding schemes; logical
(virtual) and physical addresses differ in execution-time
address-binding scheme.
Silberschatz, Galvin and Gagne ©20029.6
Memory-Management Unit (MMU)
Hardware device that maps virtual to physical address.
In MMU scheme, the value in the relocation register is
added to every address generated by a user process at
the time it is sent to memory.
The user program deals with logical addresses; it never
sees the real physical addresses.
Silberschatz, Galvin and Gagne ©20029.7
Dynamic relocation using a relocation
register
Silberschatz, Galvin and Gagne ©20029.8
Dynamic Loading
Routine is not loaded until it is called
Better memory-space utilization; unused routine is never
loaded.
Useful when large amounts of code are needed to handle
infrequently occurring cases.
No special support from the operating system is required
implemented through program design.
Silberschatz, Galvin and Gagne ©20029.9
Dynamic Linking
Linking postponed until execution time.
Small piece of code, stub, used to locate the appropriate
memory-resident library routine.
Stub replaces itself with the address of the routine, and
executes the routine.
Operating system needed to check if routine is in
processes’ memory address.
Dynamic linking is particularly useful for libraries.
Silberschatz, Galvin and Gagne ©20029.10
Overlays
Keep in memory only those instructions and data that are
needed at any given time.
Needed when process is larger than amount of memory
allocated to it.
Implemented by user, no special support needed from
operating system, programming design of overlay
structure is complex
Silberschatz, Galvin and Gagne ©20029.11
Overlays for a Two-Pass
Assembler
Silberschatz, Galvin and Gagne ©20029.12
Swapping
A process can be swapped temporarily out of memory to a
backing store, and then brought back into memory for continued
execution.
Backing store – fast disk large enough to accommodate copies
of all memory images for all users; must provide direct access to
these memory images.
Roll out, roll in – swapping variant used for priority-based
scheduling algorithms; lower-priority process is swapped out so
higher-priority process can be loaded and executed.
Major part of swap time is transfer time; total transfer time is
directly proportional to the amount of memory swapped.
Modified versions of swapping are found on many systems, i.e.,
UNIX, Linux, and Windows.
Silberschatz, Galvin and Gagne ©20029.13
Schematic View of Swapping
Silberschatz, Galvin and Gagne ©20029.14
Contiguous Allocation
Main memory usually into two partitions:
Resident operating system, usually held in low memory with
interrupt vector.
User processes then held in high memory.
Single-partition allocation
Relocation-register scheme used to protect user processes
from each other, and from changing operating-system code
and data.
Relocation register contains value of smallest physical
address; limit register contains range of logical addresses –
each logical address must be less than the limit register.
Silberschatz, Galvin and Gagne ©20029.15
Hardware Support for Relocation and Limit
Registers
Silberschatz, Galvin and Gagne ©20029.16
Contiguous Allocation (Cont.)
Multiple-partition allocation
Hole – block of available memory; holes of various size are
scattered throughout memory.
When a process arrives, it is allocated memory from a hole
large enough to accommodate it.
Operating system maintains information about:
a) allocated partitions b) free partitions (hole)
OS
process 5
process 8
process 2
OS
process 5
process 2
OS
process 5
process 2
OS
process 5
process 9
process 2
process 9
process 10
Silberschatz, Galvin and Gagne ©20029.17
Dynamic Storage-Allocation
Problem
First-fit: Allocate the first hole that is big enough.
Best-fit: Allocate the smallest hole that is big enough;
must search entire list, unless ordered by size. Produces
the smallest leftover hole.
Worst-fit: Allocate the largest hole; must also search
entire list. Produces the largest leftover hole.
How to satisfy a request of size n from a list of free holes.
First-fit and best-fit better than worst-fit in terms of
speed and storage utilization.
Silberschatz, Galvin and Gagne ©20029.18
Fragmentation
External Fragmentation – total memory space exists
to satisfy a request, but it is not contiguous.
Internal Fragmentation – allocated memory may be
slightly larger than requested memory; this size difference
is memory internal to a partition, but not being used.
Reduce external fragmentation by compaction
Shuffle memory contents to place all free memory together
in one large block.
Compaction is possible only if relocation is dynamic, and is
done at execution time.
I/O problem
Latch job in memory while it is involved in I/O.
Do I/O only into OS buffers.
Silberschatz, Galvin and Gagne ©20029.19
Paging
Logical address space of a process can be noncontiguous;
process is allocated physical memory whenever the latter is
available.
Divide physical memory into fixed-sized blocks called frames
(size is power of 2, between 512 bytes and 8192 bytes).
Divide logical memory into blocks of same size called pages.
Keep track of all free frames.
To run a program of size n pages, need to find n free frames
and load program.
Set up a page table to translate logical to physical addresses.
Internal fragmentation.
Silberschatz, Galvin and Gagne ©20029.20
Address Translation Scheme
Address generated by CPU is divided into:
Page number (p) – used as an index into a page table which
contains base address of each page in physical memory.
Page offset (d) – combined with base address to define the
physical memory address that is sent to the memory unit.
Silberschatz, Galvin and Gagne ©20029.21
Address Translation Architecture
Silberschatz, Galvin and Gagne ©20029.22
Paging Example
Silberschatz, Galvin and Gagne ©20029.23
Paging Example
Silberschatz, Galvin and Gagne ©20029.24
Free Frames
Before allocation After allocation
Silberschatz, Galvin and Gagne ©20029.25
Implementation of Page Table
Page table is kept in main memory.
Page-table base register (PTBR) points to the page table.
Page-table length register (PRLR) indicates size of the
page table.
In this scheme every data/instruction access requires two
memory accesses. One for the page table and one for
the data/instruction.
The two memory access problem can be solved by the
use of a special fast-lookup hardware cache called
associative memory or translation look-aside buffers
(TLBs)
Silberschatz, Galvin and Gagne ©20029.26
Associative Memory
Associative memory – parallel search
Address translation (A´ , A´ ´ )
If A´ is in associative register, get frame # out.
Otherwise get frame # from page table in memory
Page # Frame #
Silberschatz, Galvin and Gagne ©20029.27
Paging Hardware With TLB
Silberschatz, Galvin and Gagne ©20029.28
Effective Access Time
Associative Lookup = ε time unit
Assume memory cycle time is 1 microsecond
Hit ratio – percentage of times that a page number is
found in the associative registers; ration related to
number of associative registers.
Hit ratio = α
Effective Access Time (EAT)
EAT = (1 + ε) α + (2 + ε)(1 – α)
= 2 + ε – α
Silberschatz, Galvin and Gagne ©20029.29
Memory Protection
Memory protection implemented by associating protection
bit with each frame.
Valid-invalid bit attached to each entry in the page table:
“valid” indicates that the associated page is in the process’
logical address space, and is thus a legal page.
“invalid” indicates that the page is not in the process’ logical
address space.
Silberschatz, Galvin and Gagne ©20029.30
Valid (v) or Invalid (i) Bit In A Page
Table
Silberschatz, Galvin and Gagne ©20029.31
Page Table Structure
Hierarchical Paging
Hashed Page Tables
Inverted Page Tables
Silberschatz, Galvin and Gagne ©20029.32
Hierarchical Page Tables
Break up the logical address space into multiple page
tables.
A simple technique is a two-level page table.
Silberschatz, Galvin and Gagne ©20029.33
Two-Level Paging Example
A logical address (on 32-bit machine with 4K page size) is
divided into:
a page number consisting of 20 bits.
a page offset consisting of 12 bits.
Since the page table is paged, the page number is further
divided into:
a 10-bit page number.
a 10-bit page offset.
Thus, a logical address is as follows:
where pi is an index into the outer page table, and p2 is the
displacement within the page of the outer page table.
page number page offset
pi p2 d
10 10 12
Silberschatz, Galvin and Gagne ©20029.34
Two-Level Page-Table Scheme
Silberschatz, Galvin and Gagne ©20029.35
Address-Translation Scheme
Address-translation scheme for a two-level 32-bit paging
architecture
Silberschatz, Galvin and Gagne ©20029.36
Hashed Page Tables
Common in address spaces > 32 bits.
The virtual page number is hashed into a page table. This
page table contains a chain of elements hashing to the
same location.
Virtual page numbers are compared in this chain
searching for a match. If a match is found, the
corresponding physical frame is extracted.
Silberschatz, Galvin and Gagne ©20029.37
Hashed Page Table
Silberschatz, Galvin and Gagne ©20029.38
Inverted Page Table
One entry for each real page of memory.
Entry consists of the virtual address of the page stored in
that real memory location, with information about the
process that owns that page.
Decreases memory needed to store each page table, but
increases time needed to search the table when a page
reference occurs.
Use hash table to limit the search to one — or at most a
few — page-table entries.
Silberschatz, Galvin and Gagne ©20029.39
Inverted Page Table Architecture
Silberschatz, Galvin and Gagne ©20029.40
Shared Pages
Shared code
One copy of read-only (reentrant) code shared among
processes (i.e., text editors, compilers, window systems).
Shared code must appear in same location in the logical
address space of all processes.
Private code and data
Each process keeps a separate copy of the code and data.
The pages for the private code and data can appear
anywhere in the logical address space.
Silberschatz, Galvin and Gagne ©20029.41
Shared Pages Example
Silberschatz, Galvin and Gagne ©20029.42
Segmentation
Memory-management scheme that supports user view of
memory.
A program is a collection of segments. A segment is a logical
unit such as:
main program,
procedure,
function,
method,
object,
local variables, global variables,
common block,
stack,
symbol table, arrays
Silberschatz, Galvin and Gagne ©20029.43
User’s View of a Program
Silberschatz, Galvin and Gagne ©20029.44
Logical View of Segmentation
1
3
2
4
1
4
2
3
user space physical memory space
Silberschatz, Galvin and Gagne ©20029.45
Segmentation Architecture
Logical address consists of a two tuple:
<segment-number, offset>,
Segment table – maps two-dimensional physical
addresses; each table entry has:
base – contains the starting physical address where the
segments reside in memory.
limit – specifies the length of the segment.
Segment-table base register (STBR) points to the
segment table’s location in memory.
Segment-table length register (STLR) indicates number
of segments used by a program;
segment number s is legal if s < STLR.
Silberschatz, Galvin and Gagne ©20029.46
Segmentation Architecture (Cont.)
Relocation.
dynamic
by segment table
Sharing.
shared segments
same segment number
Allocation.
first fit/best fit
external fragmentation
Silberschatz, Galvin and Gagne ©20029.47
Segmentation Architecture (Cont.)
Protection. With each entry in segment table associate:
validation bit = 0 ⇒ illegal segment
read/write/execute privileges
Protection bits associated with segments; code sharing
occurs at segment level.
Since segments vary in length, memory allocation is a
dynamic storage-allocation problem.
A segmentation example is shown in the following
diagram
Silberschatz, Galvin and Gagne ©20029.48
Segmentation Hardware
Silberschatz, Galvin and Gagne ©20029.49
Example of Segmentation
Silberschatz, Galvin and Gagne ©20029.50
Sharing of Segments
Silberschatz, Galvin and Gagne ©20029.51
Segmentation with Paging –
MULTICS
The MULTICS system solved problems of external
fragmentation and lengthy search times by paging the
segments.
Solution differs from pure segmentation in that the
segment-table entry contains not the base address of the
segment, but rather the base address of a page table for
this segment.
Silberschatz, Galvin and Gagne ©20029.52
MULTICS Address Translation
Scheme
Silberschatz, Galvin and Gagne ©20029.53
Segmentation with Paging – Intel
386
As shown in the following diagram, the Intel 386 uses
segmentation with paging for memory management with a
two-level paging scheme.
Silberschatz, Galvin and Gagne ©20029.54
Intel 30386 Address Translation

More Related Content

What's hot

Memory technology and optimization in Advance Computer Architechture
Memory technology and optimization in Advance Computer ArchitechtureMemory technology and optimization in Advance Computer Architechture
Memory technology and optimization in Advance Computer ArchitechtureShweta Ghate
 
Memory management ppt
Memory management pptMemory management ppt
Memory management pptManishaJha43
 
Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"Ra'Fat Al-Msie'deen
 
Operating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingOperating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingguesta40f80
 
Parallel programming model
Parallel programming modelParallel programming model
Parallel programming modeleasy notes
 
03 backup-and-recovery
03 backup-and-recovery03 backup-and-recovery
03 backup-and-recoveryhunny garg
 
Operating system Memory management
Operating system Memory management Operating system Memory management
Operating system Memory management Shashank Asthana
 
Introduction to Operating System (Important Notes)
Introduction to Operating System (Important Notes)Introduction to Operating System (Important Notes)
Introduction to Operating System (Important Notes)Gaurav Kakade
 
Storage Management in Linux OS.ppt
Storage Management in Linux OS.pptStorage Management in Linux OS.ppt
Storage Management in Linux OS.pptRakesh Kadu
 
Operating system deign and implementation
Operating system deign and implementationOperating system deign and implementation
Operating system deign and implementationsangrampatil81
 
Multiprocessor
MultiprocessorMultiprocessor
MultiprocessorA B Shinde
 
parallel programming models
 parallel programming models parallel programming models
parallel programming modelsSwetha S
 
File System in Operating System
File System in Operating SystemFile System in Operating System
File System in Operating SystemMeghaj Mallick
 
Pgp pretty good privacy
Pgp pretty good privacyPgp pretty good privacy
Pgp pretty good privacyPawan Arya
 
Chapter 2: Operating System Structures
Chapter 2: Operating System StructuresChapter 2: Operating System Structures
Chapter 2: Operating System StructuresShafaan Khaliq Bhatti
 
Memory : operating system ( Btech cse )
Memory : operating system ( Btech cse )Memory : operating system ( Btech cse )
Memory : operating system ( Btech cse )HimanshuSharma1389
 
Operating system 31 multiple processor scheduling
Operating system 31 multiple processor schedulingOperating system 31 multiple processor scheduling
Operating system 31 multiple processor schedulingVaibhav Khanna
 

What's hot (20)

Cs8493 unit 2
Cs8493 unit 2Cs8493 unit 2
Cs8493 unit 2
 
Memory technology and optimization in Advance Computer Architechture
Memory technology and optimization in Advance Computer ArchitechtureMemory technology and optimization in Advance Computer Architechture
Memory technology and optimization in Advance Computer Architechture
 
Memory management ppt
Memory management pptMemory management ppt
Memory management ppt
 
Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"
 
Operating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingOperating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programming
 
Parallel programming model
Parallel programming modelParallel programming model
Parallel programming model
 
03 backup-and-recovery
03 backup-and-recovery03 backup-and-recovery
03 backup-and-recovery
 
Operating system Memory management
Operating system Memory management Operating system Memory management
Operating system Memory management
 
Introduction to Operating System (Important Notes)
Introduction to Operating System (Important Notes)Introduction to Operating System (Important Notes)
Introduction to Operating System (Important Notes)
 
Storage Management in Linux OS.ppt
Storage Management in Linux OS.pptStorage Management in Linux OS.ppt
Storage Management in Linux OS.ppt
 
Operating system deign and implementation
Operating system deign and implementationOperating system deign and implementation
Operating system deign and implementation
 
operating system structure
operating system structureoperating system structure
operating system structure
 
Multiprocessor
MultiprocessorMultiprocessor
Multiprocessor
 
parallel programming models
 parallel programming models parallel programming models
parallel programming models
 
File System in Operating System
File System in Operating SystemFile System in Operating System
File System in Operating System
 
Pgp pretty good privacy
Pgp pretty good privacyPgp pretty good privacy
Pgp pretty good privacy
 
Chapter 8 - Main Memory
Chapter 8 - Main MemoryChapter 8 - Main Memory
Chapter 8 - Main Memory
 
Chapter 2: Operating System Structures
Chapter 2: Operating System StructuresChapter 2: Operating System Structures
Chapter 2: Operating System Structures
 
Memory : operating system ( Btech cse )
Memory : operating system ( Btech cse )Memory : operating system ( Btech cse )
Memory : operating system ( Btech cse )
 
Operating system 31 multiple processor scheduling
Operating system 31 multiple processor schedulingOperating system 31 multiple processor scheduling
Operating system 31 multiple processor scheduling
 

Viewers also liked

Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memorysgpraju
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating SystemRaj Mohan
 
Combined paging and segmentation
Combined paging and segmentationCombined paging and segmentation
Combined paging and segmentationTech_MX
 
Operating System-Memory Management
Operating System-Memory ManagementOperating System-Memory Management
Operating System-Memory ManagementAkmal Cikmat
 
8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategiesDr. Loganathan R
 

Viewers also liked (9)

Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memory
 
Memory management
Memory managementMemory management
Memory management
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
Memory management
Memory managementMemory management
Memory management
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating System
 
Deadlocks
Deadlocks Deadlocks
Deadlocks
 
Combined paging and segmentation
Combined paging and segmentationCombined paging and segmentation
Combined paging and segmentation
 
Operating System-Memory Management
Operating System-Memory ManagementOperating System-Memory Management
Operating System-Memory Management
 
8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategies
 

Similar to Ch9: Memory Management

Galvin-operating System(Ch9)
Galvin-operating System(Ch9)Galvin-operating System(Ch9)
Galvin-operating System(Ch9)dsuyal1
 
운영체제론 - Ch09
운영체제론 - Ch09운영체제론 - Ch09
운영체제론 - Ch09Jongmyoung Kim
 
Chapter 9 Operating Systems silberschatz
Chapter 9 Operating Systems silberschatzChapter 9 Operating Systems silberschatz
Chapter 9 Operating Systems silberschatzGiulianoRanauro
 
OS memory management
OS memory management OS memory management
OS memory management laiba29012
 
ch8.pdf operating systems by galvin to learn
ch8.pdf operating systems by  galvin to learnch8.pdf operating systems by  galvin to learn
ch8.pdf operating systems by galvin to learnrajitha ellandula
 
ch8-1 (final Memory).pptx
ch8-1 (final Memory).pptxch8-1 (final Memory).pptx
ch8-1 (final Memory).pptxAnamRiaz31
 
2800-lecture8-memeory-management in operating system.pdf
2800-lecture8-memeory-management in operating system.pdf2800-lecture8-memeory-management in operating system.pdf
2800-lecture8-memeory-management in operating system.pdfYawkalAddis
 
OS Memory Management.pptx
OS Memory Management.pptxOS Memory Management.pptx
OS Memory Management.pptxAkshimaPurohit
 
Main memory operating system
Main memory   operating systemMain memory   operating system
Main memory operating systemIndhu Periys
 
The Council of Architecture (COA) has been constituted by the Government of I...
The Council of Architecture (COA) has been constituted by the Government of I...The Council of Architecture (COA) has been constituted by the Government of I...
The Council of Architecture (COA) has been constituted by the Government of I...OvhayKumar1
 
ch8.ppt ejejnenjfjrnjnrjngjngktgtmtommgt
ch8.ppt ejejnenjfjrnjnrjngjngktgtmtommgtch8.ppt ejejnenjfjrnjnrjngjngktgtmtommgt
ch8.ppt ejejnenjfjrnjnrjngjngktgtmtommgtaaravjamela
 

Similar to Ch9: Memory Management (20)

Galvin-operating System(Ch9)
Galvin-operating System(Ch9)Galvin-operating System(Ch9)
Galvin-operating System(Ch9)
 
Main memory-2 (ch8,os)
Main memory-2 (ch8,os)Main memory-2 (ch8,os)
Main memory-2 (ch8,os)
 
운영체제론 - Ch09
운영체제론 - Ch09운영체제론 - Ch09
운영체제론 - Ch09
 
ch9.pptx
ch9.pptxch9.pptx
ch9.pptx
 
ch9.pptx
ch9.pptxch9.pptx
ch9.pptx
 
Chapter 9 Operating Systems silberschatz
Chapter 9 Operating Systems silberschatzChapter 9 Operating Systems silberschatz
Chapter 9 Operating Systems silberschatz
 
OS memory management
OS memory management OS memory management
OS memory management
 
Ch07
Ch07Ch07
Ch07
 
Paging.ppt
Paging.pptPaging.ppt
Paging.ppt
 
ch8.pdf operating systems by galvin to learn
ch8.pdf operating systems by  galvin to learnch8.pdf operating systems by  galvin to learn
ch8.pdf operating systems by galvin to learn
 
Ch8
Ch8Ch8
Ch8
 
ch8-1 (final Memory).pptx
ch8-1 (final Memory).pptxch8-1 (final Memory).pptx
ch8-1 (final Memory).pptx
 
2800-lecture8-memeory-management in operating system.pdf
2800-lecture8-memeory-management in operating system.pdf2800-lecture8-memeory-management in operating system.pdf
2800-lecture8-memeory-management in operating system.pdf
 
OS Memory Management.pptx
OS Memory Management.pptxOS Memory Management.pptx
OS Memory Management.pptx
 
ch8.ppt
ch8.pptch8.ppt
ch8.ppt
 
ch8 (2).ppt
ch8 (2).pptch8 (2).ppt
ch8 (2).ppt
 
Main memory operating system
Main memory   operating systemMain memory   operating system
Main memory operating system
 
The Council of Architecture (COA) has been constituted by the Government of I...
The Council of Architecture (COA) has been constituted by the Government of I...The Council of Architecture (COA) has been constituted by the Government of I...
The Council of Architecture (COA) has been constituted by the Government of I...
 
ch8.ppt ejejnenjfjrnjnrjngjngktgtmtommgt
ch8.ppt ejejnenjfjrnjnrjngjngktgtmtommgtch8.ppt ejejnenjfjrnjnrjngjngktgtmtommgt
ch8.ppt ejejnenjfjrnjnrjngjngktgtmtommgt
 
ch8.ppt
ch8.pptch8.ppt
ch8.ppt
 

More from Ahmar Hashmi

32 Security in_Internet_IP_SEC_SSL/TLS_PGN_VPN_and_Firewalls
32 Security in_Internet_IP_SEC_SSL/TLS_PGN_VPN_and_Firewalls32 Security in_Internet_IP_SEC_SSL/TLS_PGN_VPN_and_Firewalls
32 Security in_Internet_IP_SEC_SSL/TLS_PGN_VPN_and_FirewallsAhmar Hashmi
 
31 Network Security
31 Network Security31 Network Security
31 Network SecurityAhmar Hashmi
 
28 Network Management_SNMP
28 Network Management_SNMP28 Network Management_SNMP
28 Network Management_SNMPAhmar Hashmi
 
26 Remote Logging_Electronic_Mail_and_File_Transfer
26 Remote Logging_Electronic_Mail_and_File_Transfer26 Remote Logging_Electronic_Mail_and_File_Transfer
26 Remote Logging_Electronic_Mail_and_File_TransferAhmar Hashmi
 
24 Congestion Control_and_Quality_of_Service
24 Congestion Control_and_Quality_of_Service24 Congestion Control_and_Quality_of_Service
24 Congestion Control_and_Quality_of_ServiceAhmar Hashmi
 
23 Process to_Process_Delivery_UDP_TCP_and_SCTP
23 Process to_Process_Delivery_UDP_TCP_and_SCTP23 Process to_Process_Delivery_UDP_TCP_and_SCTP
23 Process to_Process_Delivery_UDP_TCP_and_SCTPAhmar Hashmi
 
22 Network Layer_Delivery_forwarding_and_Routing
22 Network Layer_Delivery_forwarding_and_Routing22 Network Layer_Delivery_forwarding_and_Routing
22 Network Layer_Delivery_forwarding_and_RoutingAhmar Hashmi
 
21 Network Layer_Address_Mapping_Error_Reporting_and_Multicasting
21 Network Layer_Address_Mapping_Error_Reporting_and_Multicasting21 Network Layer_Address_Mapping_Error_Reporting_and_Multicasting
21 Network Layer_Address_Mapping_Error_Reporting_and_MulticastingAhmar Hashmi
 
20 Network Layer_Internet_Protocol
20 Network Layer_Internet_Protocol20 Network Layer_Internet_Protocol
20 Network Layer_Internet_ProtocolAhmar Hashmi
 
19 Network Layer_Logical_Addressing
19 Network Layer_Logical_Addressing19 Network Layer_Logical_Addressing
19 Network Layer_Logical_AddressingAhmar Hashmi
 
18 Virtual Circuit_Networks_Frame_Relay_and_ATM
18 Virtual Circuit_Networks_Frame_Relay_and_ATM18 Virtual Circuit_Networks_Frame_Relay_and_ATM
18 Virtual Circuit_Networks_Frame_Relay_and_ATMAhmar Hashmi
 
16 Wireless WANs_Cellular_Telephone_and_Satellite_Networks
16 Wireless WANs_Cellular_Telephone_and_Satellite_Networks16 Wireless WANs_Cellular_Telephone_and_Satellite_Networks
16 Wireless WANs_Cellular_Telephone_and_Satellite_NetworksAhmar Hashmi
 
15 Connecting LANs_Backbone_Networks_and_Virtual_LAN
15 Connecting LANs_Backbone_Networks_and_Virtual_LAN15 Connecting LANs_Backbone_Networks_and_Virtual_LAN
15 Connecting LANs_Backbone_Networks_and_Virtual_LANAhmar Hashmi
 
13 Wired Lans_Ethernet
13 Wired Lans_Ethernet13 Wired Lans_Ethernet
13 Wired Lans_EthernetAhmar Hashmi
 

More from Ahmar Hashmi (20)

32 Security in_Internet_IP_SEC_SSL/TLS_PGN_VPN_and_Firewalls
32 Security in_Internet_IP_SEC_SSL/TLS_PGN_VPN_and_Firewalls32 Security in_Internet_IP_SEC_SSL/TLS_PGN_VPN_and_Firewalls
32 Security in_Internet_IP_SEC_SSL/TLS_PGN_VPN_and_Firewalls
 
31 Network Security
31 Network Security31 Network Security
31 Network Security
 
30 Cryptography
30 Cryptography30 Cryptography
30 Cryptography
 
29 Multimedia
29 Multimedia29 Multimedia
29 Multimedia
 
28 Network Management_SNMP
28 Network Management_SNMP28 Network Management_SNMP
28 Network Management_SNMP
 
27 WWW and_HTTP
27 WWW and_HTTP27 WWW and_HTTP
27 WWW and_HTTP
 
26 Remote Logging_Electronic_Mail_and_File_Transfer
26 Remote Logging_Electronic_Mail_and_File_Transfer26 Remote Logging_Electronic_Mail_and_File_Transfer
26 Remote Logging_Electronic_Mail_and_File_Transfer
 
25 DNS
25 DNS25 DNS
25 DNS
 
24 Congestion Control_and_Quality_of_Service
24 Congestion Control_and_Quality_of_Service24 Congestion Control_and_Quality_of_Service
24 Congestion Control_and_Quality_of_Service
 
23 Process to_Process_Delivery_UDP_TCP_and_SCTP
23 Process to_Process_Delivery_UDP_TCP_and_SCTP23 Process to_Process_Delivery_UDP_TCP_and_SCTP
23 Process to_Process_Delivery_UDP_TCP_and_SCTP
 
22 Network Layer_Delivery_forwarding_and_Routing
22 Network Layer_Delivery_forwarding_and_Routing22 Network Layer_Delivery_forwarding_and_Routing
22 Network Layer_Delivery_forwarding_and_Routing
 
21 Network Layer_Address_Mapping_Error_Reporting_and_Multicasting
21 Network Layer_Address_Mapping_Error_Reporting_and_Multicasting21 Network Layer_Address_Mapping_Error_Reporting_and_Multicasting
21 Network Layer_Address_Mapping_Error_Reporting_and_Multicasting
 
20 Network Layer_Internet_Protocol
20 Network Layer_Internet_Protocol20 Network Layer_Internet_Protocol
20 Network Layer_Internet_Protocol
 
19 Network Layer_Logical_Addressing
19 Network Layer_Logical_Addressing19 Network Layer_Logical_Addressing
19 Network Layer_Logical_Addressing
 
18 Virtual Circuit_Networks_Frame_Relay_and_ATM
18 Virtual Circuit_Networks_Frame_Relay_and_ATM18 Virtual Circuit_Networks_Frame_Relay_and_ATM
18 Virtual Circuit_Networks_Frame_Relay_and_ATM
 
17 SONET/SDH
17 SONET/SDH17 SONET/SDH
17 SONET/SDH
 
16 Wireless WANs_Cellular_Telephone_and_Satellite_Networks
16 Wireless WANs_Cellular_Telephone_and_Satellite_Networks16 Wireless WANs_Cellular_Telephone_and_Satellite_Networks
16 Wireless WANs_Cellular_Telephone_and_Satellite_Networks
 
15 Connecting LANs_Backbone_Networks_and_Virtual_LAN
15 Connecting LANs_Backbone_Networks_and_Virtual_LAN15 Connecting LANs_Backbone_Networks_and_Virtual_LAN
15 Connecting LANs_Backbone_Networks_and_Virtual_LAN
 
14 Wireless LAN
14 Wireless LAN14 Wireless LAN
14 Wireless LAN
 
13 Wired Lans_Ethernet
13 Wired Lans_Ethernet13 Wired Lans_Ethernet
13 Wired Lans_Ethernet
 

Recently uploaded

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 

Recently uploaded (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 

Ch9: Memory Management

  • 1. Silberschatz, Galvin and Gagne ©20029.1 Chapter 9: Memory Management Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging
  • 2. Silberschatz, Galvin and Gagne ©20029.2 Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are waiting to be brought into memory to run the program. User programs go through several steps before being run.
  • 3. Silberschatz, Galvin and Gagne ©20029.3 Binding of Instructions and Data to Memory Compile time: If memory location known a priori, absolute code can be generated; must recompile code if starting location changes. Load time: Must generate relocatable code if memory location is not known at compile time. Execution time: Binding delayed until run time if the process can be moved during its execution from one memory segment to another. Need hardware support for address maps (e.g., base and limit registers). Address binding of instructions and data to memory addresses can happen at three different stages.
  • 4. Silberschatz, Galvin and Gagne ©20029.4 Multistep Processing of a User Program
  • 5. Silberschatz, Galvin and Gagne ©20029.5 Logical vs. Physical Address Space The concept of a logical address space that is bound to a separate physical address space is central to proper memory management. Logical address – generated by the CPU; also referred to as virtual address. Physical address – address seen by the memory unit. Logical and physical addresses are the same in compile- time and load-time address-binding schemes; logical (virtual) and physical addresses differ in execution-time address-binding scheme.
  • 6. Silberschatz, Galvin and Gagne ©20029.6 Memory-Management Unit (MMU) Hardware device that maps virtual to physical address. In MMU scheme, the value in the relocation register is added to every address generated by a user process at the time it is sent to memory. The user program deals with logical addresses; it never sees the real physical addresses.
  • 7. Silberschatz, Galvin and Gagne ©20029.7 Dynamic relocation using a relocation register
  • 8. Silberschatz, Galvin and Gagne ©20029.8 Dynamic Loading Routine is not loaded until it is called Better memory-space utilization; unused routine is never loaded. Useful when large amounts of code are needed to handle infrequently occurring cases. No special support from the operating system is required implemented through program design.
  • 9. Silberschatz, Galvin and Gagne ©20029.9 Dynamic Linking Linking postponed until execution time. Small piece of code, stub, used to locate the appropriate memory-resident library routine. Stub replaces itself with the address of the routine, and executes the routine. Operating system needed to check if routine is in processes’ memory address. Dynamic linking is particularly useful for libraries.
  • 10. Silberschatz, Galvin and Gagne ©20029.10 Overlays Keep in memory only those instructions and data that are needed at any given time. Needed when process is larger than amount of memory allocated to it. Implemented by user, no special support needed from operating system, programming design of overlay structure is complex
  • 11. Silberschatz, Galvin and Gagne ©20029.11 Overlays for a Two-Pass Assembler
  • 12. Silberschatz, Galvin and Gagne ©20029.12 Swapping A process can be swapped temporarily out of memory to a backing store, and then brought back into memory for continued execution. Backing store – fast disk large enough to accommodate copies of all memory images for all users; must provide direct access to these memory images. Roll out, roll in – swapping variant used for priority-based scheduling algorithms; lower-priority process is swapped out so higher-priority process can be loaded and executed. Major part of swap time is transfer time; total transfer time is directly proportional to the amount of memory swapped. Modified versions of swapping are found on many systems, i.e., UNIX, Linux, and Windows.
  • 13. Silberschatz, Galvin and Gagne ©20029.13 Schematic View of Swapping
  • 14. Silberschatz, Galvin and Gagne ©20029.14 Contiguous Allocation Main memory usually into two partitions: Resident operating system, usually held in low memory with interrupt vector. User processes then held in high memory. Single-partition allocation Relocation-register scheme used to protect user processes from each other, and from changing operating-system code and data. Relocation register contains value of smallest physical address; limit register contains range of logical addresses – each logical address must be less than the limit register.
  • 15. Silberschatz, Galvin and Gagne ©20029.15 Hardware Support for Relocation and Limit Registers
  • 16. Silberschatz, Galvin and Gagne ©20029.16 Contiguous Allocation (Cont.) Multiple-partition allocation Hole – block of available memory; holes of various size are scattered throughout memory. When a process arrives, it is allocated memory from a hole large enough to accommodate it. Operating system maintains information about: a) allocated partitions b) free partitions (hole) OS process 5 process 8 process 2 OS process 5 process 2 OS process 5 process 2 OS process 5 process 9 process 2 process 9 process 10
  • 17. Silberschatz, Galvin and Gagne ©20029.17 Dynamic Storage-Allocation Problem First-fit: Allocate the first hole that is big enough. Best-fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by size. Produces the smallest leftover hole. Worst-fit: Allocate the largest hole; must also search entire list. Produces the largest leftover hole. How to satisfy a request of size n from a list of free holes. First-fit and best-fit better than worst-fit in terms of speed and storage utilization.
  • 18. Silberschatz, Galvin and Gagne ©20029.18 Fragmentation External Fragmentation – total memory space exists to satisfy a request, but it is not contiguous. Internal Fragmentation – allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used. Reduce external fragmentation by compaction Shuffle memory contents to place all free memory together in one large block. Compaction is possible only if relocation is dynamic, and is done at execution time. I/O problem Latch job in memory while it is involved in I/O. Do I/O only into OS buffers.
  • 19. Silberschatz, Galvin and Gagne ©20029.19 Paging Logical address space of a process can be noncontiguous; process is allocated physical memory whenever the latter is available. Divide physical memory into fixed-sized blocks called frames (size is power of 2, between 512 bytes and 8192 bytes). Divide logical memory into blocks of same size called pages. Keep track of all free frames. To run a program of size n pages, need to find n free frames and load program. Set up a page table to translate logical to physical addresses. Internal fragmentation.
  • 20. Silberschatz, Galvin and Gagne ©20029.20 Address Translation Scheme Address generated by CPU is divided into: Page number (p) – used as an index into a page table which contains base address of each page in physical memory. Page offset (d) – combined with base address to define the physical memory address that is sent to the memory unit.
  • 21. Silberschatz, Galvin and Gagne ©20029.21 Address Translation Architecture
  • 22. Silberschatz, Galvin and Gagne ©20029.22 Paging Example
  • 23. Silberschatz, Galvin and Gagne ©20029.23 Paging Example
  • 24. Silberschatz, Galvin and Gagne ©20029.24 Free Frames Before allocation After allocation
  • 25. Silberschatz, Galvin and Gagne ©20029.25 Implementation of Page Table Page table is kept in main memory. Page-table base register (PTBR) points to the page table. Page-table length register (PRLR) indicates size of the page table. In this scheme every data/instruction access requires two memory accesses. One for the page table and one for the data/instruction. The two memory access problem can be solved by the use of a special fast-lookup hardware cache called associative memory or translation look-aside buffers (TLBs)
  • 26. Silberschatz, Galvin and Gagne ©20029.26 Associative Memory Associative memory – parallel search Address translation (A´ , A´ ´ ) If A´ is in associative register, get frame # out. Otherwise get frame # from page table in memory Page # Frame #
  • 27. Silberschatz, Galvin and Gagne ©20029.27 Paging Hardware With TLB
  • 28. Silberschatz, Galvin and Gagne ©20029.28 Effective Access Time Associative Lookup = ε time unit Assume memory cycle time is 1 microsecond Hit ratio – percentage of times that a page number is found in the associative registers; ration related to number of associative registers. Hit ratio = α Effective Access Time (EAT) EAT = (1 + ε) α + (2 + ε)(1 – α) = 2 + ε – α
  • 29. Silberschatz, Galvin and Gagne ©20029.29 Memory Protection Memory protection implemented by associating protection bit with each frame. Valid-invalid bit attached to each entry in the page table: “valid” indicates that the associated page is in the process’ logical address space, and is thus a legal page. “invalid” indicates that the page is not in the process’ logical address space.
  • 30. Silberschatz, Galvin and Gagne ©20029.30 Valid (v) or Invalid (i) Bit In A Page Table
  • 31. Silberschatz, Galvin and Gagne ©20029.31 Page Table Structure Hierarchical Paging Hashed Page Tables Inverted Page Tables
  • 32. Silberschatz, Galvin and Gagne ©20029.32 Hierarchical Page Tables Break up the logical address space into multiple page tables. A simple technique is a two-level page table.
  • 33. Silberschatz, Galvin and Gagne ©20029.33 Two-Level Paging Example A logical address (on 32-bit machine with 4K page size) is divided into: a page number consisting of 20 bits. a page offset consisting of 12 bits. Since the page table is paged, the page number is further divided into: a 10-bit page number. a 10-bit page offset. Thus, a logical address is as follows: where pi is an index into the outer page table, and p2 is the displacement within the page of the outer page table. page number page offset pi p2 d 10 10 12
  • 34. Silberschatz, Galvin and Gagne ©20029.34 Two-Level Page-Table Scheme
  • 35. Silberschatz, Galvin and Gagne ©20029.35 Address-Translation Scheme Address-translation scheme for a two-level 32-bit paging architecture
  • 36. Silberschatz, Galvin and Gagne ©20029.36 Hashed Page Tables Common in address spaces > 32 bits. The virtual page number is hashed into a page table. This page table contains a chain of elements hashing to the same location. Virtual page numbers are compared in this chain searching for a match. If a match is found, the corresponding physical frame is extracted.
  • 37. Silberschatz, Galvin and Gagne ©20029.37 Hashed Page Table
  • 38. Silberschatz, Galvin and Gagne ©20029.38 Inverted Page Table One entry for each real page of memory. Entry consists of the virtual address of the page stored in that real memory location, with information about the process that owns that page. Decreases memory needed to store each page table, but increases time needed to search the table when a page reference occurs. Use hash table to limit the search to one — or at most a few — page-table entries.
  • 39. Silberschatz, Galvin and Gagne ©20029.39 Inverted Page Table Architecture
  • 40. Silberschatz, Galvin and Gagne ©20029.40 Shared Pages Shared code One copy of read-only (reentrant) code shared among processes (i.e., text editors, compilers, window systems). Shared code must appear in same location in the logical address space of all processes. Private code and data Each process keeps a separate copy of the code and data. The pages for the private code and data can appear anywhere in the logical address space.
  • 41. Silberschatz, Galvin and Gagne ©20029.41 Shared Pages Example
  • 42. Silberschatz, Galvin and Gagne ©20029.42 Segmentation Memory-management scheme that supports user view of memory. A program is a collection of segments. A segment is a logical unit such as: main program, procedure, function, method, object, local variables, global variables, common block, stack, symbol table, arrays
  • 43. Silberschatz, Galvin and Gagne ©20029.43 User’s View of a Program
  • 44. Silberschatz, Galvin and Gagne ©20029.44 Logical View of Segmentation 1 3 2 4 1 4 2 3 user space physical memory space
  • 45. Silberschatz, Galvin and Gagne ©20029.45 Segmentation Architecture Logical address consists of a two tuple: <segment-number, offset>, Segment table – maps two-dimensional physical addresses; each table entry has: base – contains the starting physical address where the segments reside in memory. limit – specifies the length of the segment. Segment-table base register (STBR) points to the segment table’s location in memory. Segment-table length register (STLR) indicates number of segments used by a program; segment number s is legal if s < STLR.
  • 46. Silberschatz, Galvin and Gagne ©20029.46 Segmentation Architecture (Cont.) Relocation. dynamic by segment table Sharing. shared segments same segment number Allocation. first fit/best fit external fragmentation
  • 47. Silberschatz, Galvin and Gagne ©20029.47 Segmentation Architecture (Cont.) Protection. With each entry in segment table associate: validation bit = 0 ⇒ illegal segment read/write/execute privileges Protection bits associated with segments; code sharing occurs at segment level. Since segments vary in length, memory allocation is a dynamic storage-allocation problem. A segmentation example is shown in the following diagram
  • 48. Silberschatz, Galvin and Gagne ©20029.48 Segmentation Hardware
  • 49. Silberschatz, Galvin and Gagne ©20029.49 Example of Segmentation
  • 50. Silberschatz, Galvin and Gagne ©20029.50 Sharing of Segments
  • 51. Silberschatz, Galvin and Gagne ©20029.51 Segmentation with Paging – MULTICS The MULTICS system solved problems of external fragmentation and lengthy search times by paging the segments. Solution differs from pure segmentation in that the segment-table entry contains not the base address of the segment, but rather the base address of a page table for this segment.
  • 52. Silberschatz, Galvin and Gagne ©20029.52 MULTICS Address Translation Scheme
  • 53. Silberschatz, Galvin and Gagne ©20029.53 Segmentation with Paging – Intel 386 As shown in the following diagram, the Intel 386 uses segmentation with paging for memory management with a two-level paging scheme.
  • 54. Silberschatz, Galvin and Gagne ©20029.54 Intel 30386 Address Translation