Ch-9B - OS Main Memory2
Ch-9B - OS Main Memory2
CS3500
PROF. SUKHENDU DAS DEPTT. OF COMPUTER SCIENCE
AND ENGG., IIT MADRAS, CHENNAI – 600036.
Email: [email protected]
URL: http://www.cse.iitm.ac.in/~vplab/os.html
Oct . – 2022.
MAIN MEMORY - II
OUTLINE
• Swapping
• Example: The Intel 32 Architecture
• Example: 64-bit Architecture
• Example: The Intel IA-32 Architecture
• Example: ARMv8 Architecture
SWAPPING (CONT.)
• Does the swapped out process need to swap back in to same physical
addresses?
• Depends on address binding method
• Plus consider pending I/O to/from process memory space
• Modified versions of swapping are found on many systems (i.e., UNIX,
Linux, and Windows)
• Swapping normally disabled
• Started if more than threshold amount of memory allocated
• Disabled again once memory demand reduced below threshold
SCHEMATIC VIEW OF SWAPPING
CONTEXT SWITCH TIME INCLUDING SWAPPING
• If next processes to be put on CPU is not in memory, need to swap out a
process and swap in target process
• Context switch time can then be very high
• 100MB process swapping to hard disk with transfer rate of 50MB/sec
• Swap out time of 2000 ms
• Plus swap in of same sized process
• Total context switch swapping component time of 4000ms (4 seconds)
• Can reduce if reduce size of memory swapped – by knowing how much
memory really being used
• System calls to inform OS of memory use via request_memory() and
release_memory()
CONTEXT SWITCH TIME AND SWAPPING (CONT.)
• Other constraints as well on swapping
• Pending I/O – can’t swap out as I/O would occur to wrong
process
• Or always transfer I/O to kernel space, then to I/O device
• Known as double buffering, adds overhead
• Standard swapping not used in modern operating systems
• But modified version common
• Swap only when free memory extremely low
SWAPPING ON MOBILE SYSTEMS
• Not typically supported
• Flash memory based
• Small amount of space
• Limited number of write cycles
• Poor throughput between flash memory and CPU on mobile platform
• Instead use other methods to free memory if low
• iOS asks apps to voluntarily relinquish allocated memory
• Read-only data thrown out and reloaded from flash if needed
• Failure to free can result in termination
• Android terminates apps if low free memory, but first writes application state
to flash for fast restart
SWAPPING WITH PAGING
EXAMPLE: THE INTEL 32 AND 64-BIT ARCHITECTURES
Machine has six segment registers, allowing six segments to be addressed at any
one time by a process. It also has six 8-byte microprogram registers
For 4-KB pages, IA-32 uses a two-level paging scheme in which the
division of the 32-bit linear address is as follows:
INTEL IA-32 PAGING ARCHITECTURE
How 36 ?
12-bit offset
+
(*) 24-bit base address
of page
table/frames
In all page table formats supported by x86 and x86-64, the 12 least
significant bits of the page table entry are either interpreted by the
memory management unit or are reserved for operating system use. In
processors that implement the "no-execute" or "execution disable"
feature, the most significant bit (bit 63) is the NX bit. The next eleven
most significant bits (bits 52 through 62) are reserved for operating
system use by both Intel and AMD's architecture specifications. Thus,
from 64 bits in the page table entry, 12 low-order and 12 high-order bits
have other uses, leaving 40 bits (bits 12 though 51) for the physical
page number. Combined with 12 bits of "offset within page" from the
linear address, a maximum of 52 bits are available to address physical
memory. This allows a maximum RAM configuration of 252 bytes, or
4 petabytes (about 4.5×1015 bytes).
https://en.wikipedia.org/wiki/Physical_Address_Extension
INTEL X86-64
Current generation Intel x86 architecture
64 bits is ginormous (> 16 exabytes)
In practice only implement 48 bit addressing
• Page sizes of 4 KB, 2 MB, 1 GB
• Four levels of paging hierarchy
Can also use PAE so virtual addresses are 48 bits and physical
addresses are 52 bits
EXAMPLE: ARM ARCHITECTURE
Dominant mobile platform chip
(Apple iOS and Google Android
devices for example) 32 bits
Modern, energy efficient, 32-bit CPU outer page inner page offset
4 KB and 16 KB pages
1 MB and 16 MB pages (termed 4-KB
sections) or
16-KB
One-level paging for sections, two- page