Unit 3 Memory Management & Virtual Memory.pdf - Google Drive
Recommend Documents
You should have noticed in project 2 that the virtual memory system was very
limited. ▫ Processes limited to one page of stack. ▫ System limited to the amount of
...
No preview available. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Vi
Sign in. Loading⦠Whoops! There was a problem loading more pages. Whoops! There was a problem previewing this document
No preview available. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Vi
There was a problem loading more pages. pdf virtual memory. pdf virtual memory. Open. Extract. Open with. Sign In. Main
There are more words than you need. take risks ⢠steep ⢠hurt myself ⢠fascinated ⢠give me a thrill ⢠go trek
faster than AWT )nets. ... iq,i .rze and arc raid out using the square ofa grid. .... A rir.rl-Lokshmonon A.P-CSE. Page
things, the assembler may find out syntax errors. The logical errors or other. programming errors are not found out by t
for the mnemonics and data in the assembly language program. ... data type that may be a constant, variable, string, etc
when logical address space is small. Dynamic loading A routine is loaded only when it's called. Definitions. Page 4 of 2
Operating System Concepts. Chapter 9: Virtual Memory. ▫ Background. ▫
Demand Paging. ▫ Process Creation. ▫ Page Replacement. ▫ Allocation of
Frames.
Virtual memory achieves a complete separation of logical and physical address-
... Virtual memory is divided into chunks called pages; size of a page is equal to ...
4 Last year I went to live in a big city. At first I didn't. have any friends and I was really ______. 5 My little broth
Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. UNIT 3 EXTENSION AK.pdf.
Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Unit 3 HTML Attributes.P
... static equilibrium. What is the mass of the block on the ramp? kg. 30Ã T. T1. 2. Page 2 of 3 ... Unit 4 WS 3.pdf. U
Ipoma, Kelly 205481 B 85.00% 3.00 4 4 3 2 2 3. Jackson, Carmen 620325 D- 61.00% 1.50 2 1 1 2 1 2. Johnson, LarTerrious 2
Calorimetry (q = CâT & above. formulas). 2. Page 2 of 107. Page 3 of 107. Unit Outline. Chemical Reactions. PE Dia
5) What is Feedback Control? ... âAn enterprise which own or control production or service facilities outside the coun
Page 1 of 1. MAHALAKSHMI. ENGINEERING COLLEGE. TIRUCHIRAPALLI - 621213. QUESTION WITH ANSWERS. DEPT: CIVIL âIV SEM:VII
Te soil mass is an elastic medium for which the modulus of elasticity E is. constant. The soil mass is âIsotropicâ t
20) Define Organizational conflict. According to step âconflict is a process in which an effort is purposefully made b
web application. JSP pages are easier to maintain then a Servlet. JSP pages are opposite of. Servlets. Servlet adds HTML
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to op
Unit 3 Memory Management & Virtual Memory.pdf - Google Drive
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to op
Unit No: 3 Memory Management & Virtual Memory
Pavan R Jaiswal
Swapping Demand paging Memory management requirements Memory partitioning Paging, segmentation Security issues Hardware & control structures Linux & Windows memory management Android memory management
Memory Mgmt & Virtual Memory
2
Memory management policies ◦ Allocating swap space
◦ Freeing swap space ◦ Swapping
◦ Demand paging
Memory Mgmt & Virtual Memory
3
Primary memory is a precious resource that frequently cannot
contain all active processes in the system
The memory management system decides which processes should reside (at least partially) in main memory
It monitors the amount of available primary memory and may periodically write processes to a secondary device called the swap device to provide more space in primary memory
At a later time, the kernel reads the data from swap device back to main memory
Memory Mgmt & Virtual Memory
4
Kernel Process Table
Kernel Region Table
A Process
Per Process Region Table Text File Descriptor Table
Data Stack
U Area
Fig 1 Data structures of process Memory Mgmt & Virtual Memory
5
per process region table
Kernel region table
u area
Kernel process table
main memory
Fig 1 Data structures of process Memory Mgmt & Virtual Memory
6
Swapping
◦ Easy to implement ◦ Less system overhead Demand
The swap device is a block device in a configurable section of a disk
Kernel allocates contiguous space on the swap device
without fragmentation
It maintains free space of the swap device in an in-core table, called map
The kernel treats each unit of the swap map as group of disk blocks
As kernel allocates and frees resources, it updates the map accordingly Memory Mgmt & Virtual Memory
8
Address
1
Unit
10000
Allocate 100 unit
101
9900
Map Allocate 50 unit
251
9850
Allocate 100 unit
151
9750
Fig 2 Allocating swap space Memory Mgmt & Virtual Memory
9
Address 251
Unit 9750
50 unit free at 101
101
50
251
9750
Map
Case 1: Free resources fill a hole, but not contiguous to any resources in the map
Fig 3 freeing swap space Memory Mgmt & Virtual Memory
10
Address 251
Unit 9750
50 unit free at 101
101
50
251
9750
Map 100 unit free at 1
1 251
150 9750
Case 2: Free resources fill a hole, and immediately precedes an entry in the map Memory Mgmt & Virtual Memory
11
Address
Unit
251
9750
50 unit free at 101
101
50
251
9750
Map 100 unit free at 1
1
451
150
Allocate 200 unit
9550 300 unit free at 151
1
10000
1 251
150 9750
Case 3: Free resources fill a hole, and completely fills the gap between entries in the map
Memory Mgmt & Virtual Memory
12
malloc( address_of_map, number_of_unit) ◦ for (every map entry) if (current map entry can fit requested units) if (requested units == number of units in entry) Delete entry from map
else Adjust start address of entry
return original address of entry
◦ return -1
Memory Mgmt & Virtual Memory
13
Memory Swap device Kernel swap out when it needs memory 1. When fork() is called for allocating child process 2. When called for increasing the size of process 3. When process become larger by growth of its stack 4. Previously swapped out process want to swap in but not enough memory Memory Mgmt & Virtual Memory
14
The kernel must gather the page addresses of data at primary memory to be swapped out
Kernel copies the physical memory assigned to a process to the allocated space on the
swap device
The mapping between physical memory and swap device is kept in page table entry Memory Mgmt & Virtual Memory
15
Physical Addresses
Virtual Addresses
Text
Swap device 684
0
278k
1k
432k :
Data 65k
573k
66k
595k
690
:
Stack 128k
401k :
Fig 4 Mapping process onto the swap device Memory Mgmt & Virtual Memory
16
Physical Addresses
Virtual Addresses
Text
Swap device 684
0
278k
1k
432k :
Data 65k
573k
66k
595k
690
:
Stack 128k
401k :
Fig 5 Swapping a process into memory Memory Mgmt & Virtual Memory
17
There may not be enough memory when fork() called
Child process swap out and “ready-to-run”
Swap in when kernel schedule it
Memory Mgmt & Virtual Memory
18
It reserves enough space on the swap device to contain the
memory space of the process, including the newly requested space
Then it adjust the address translation mapping of the process
Finally, it swaps the process out on newly allocated space in swapping device
When the process swaps the process into memory, it will allocate
physical
memory
according
to
new
address
translation map
Memory Mgmt & Virtual Memory
19
Not all pages of process resides in memory
Locality of reference
When a process accesses a page that is not part of its working set, it incurs a page fault.
The kernel suspends the execution of the
process until it reads the page into memory and makes it accessible to the process Memory Mgmt & Virtual Memory
20
Page table entry
Disk block descriptors
Page frame data table
Swap use table
Memory Mgmt & Virtual Memory
21
Fig 6 PTE and DBD Memory Mgmt & Virtual Memory
22
Contains the physical address of page and the
following bits: ◦ Valid: whether the page contents are legal ◦ Reference: whether the page is referenced recently
◦ Modify: whether the page content is modified ◦ copy on write: kernel must create a new copy when a process modifies its contents (required for fork) ◦ Age: Age of the page ◦ Protection: Read/ write permission
Memory Mgmt & Virtual Memory
23
Swap Device number as there may be several swap devices
Block number that contains page
Swap device
Block num
Type
Memory Mgmt & Virtual Memory
24
Basic requirements of Memory Management
Memory Partitioning
Basic blocks of memory management ◦ Paging ◦ Segmentation
Page replacement algorithms
Memory Mgmt & Virtual Memory
25
Memory is cheap today, and getting cheaper ◦ But applications are demanding more and more memory that is never enough!
Memory
Management,
involves
swapping
blocks of data from secondary storage.
Memory I/O is slow compared to a CPU
Memory Mgmt & Virtual Memory
26
Memory needs to be allocated to ensure a
reasonable supply of ready processes to consume available processor time
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
Memory Mgmt & Virtual Memory
29
Memory Management Terms
Term
Description
Frame
Fixed-length
Page
Fixed-length
Segment
Variable-length block of data that
memory.
block
of
main
block of data in secondary memory (e.g. on disk).
resides in secondary memory.
Memory Mgmt & Virtual Memory
30
Fig 7 Addressing requirements of process Memory Mgmt & Virtual Memory
31
Processes should not be able to reference memory locations of another process without its permission
It is not possible to check absolute addresses at compile time
It must be checked at run time
Memory Mgmt & Virtual Memory
32
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 having their own separate copy
Memory Mgmt & Virtual Memory
33
Memory is organized linearly
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
Segmentation helps here
Memory Mgmt & Virtual Memory
34
Cannot
leave
the
programmer
with
the
responsibility to manage memory
Memory available for a program plus its data may be insufficient ◦ Overlaying allows various modules to be assigned the same region of memory but is time consuming to program
Programmer does not know how much space will be available Memory Mgmt & Virtual Memory
35
Fixed partitioning
Dynamic partitioning
Simple paging
Simple segmentation
Virtual memory paging
Virtual memory segmentation
Memory Mgmt & Virtual Memory
36
Equal-size partitions ◦ 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
Memory Mgmt & Virtual Memory
37
A program may not fit in a partition. ◦ The programmer must design the program with overlays
Main memory use is inefficient. ◦ Any program, no matter how small, occupies an entire partition. ◦ This results in internal fragmentation.
Memory Mgmt & Virtual Memory
38
both problems ◦ but doesn’t solve completely
In Fig ◦ Programs up to 16M can be accommodated without overlay ◦ Smaller programs can be placed in smaller partitions, reducing internal fragmentation
Memory Mgmt & Virtual Memory
39
Equal-size ◦ Placement is trivial (no options)
Unequal-size ◦ Can assign each process to the smallest partition within which it will fit ◦ Queue for each partition
◦ Processes are assigned in such a way that memory wastage within partition can be minimized
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 ◦ Memory compaction must be done more often
Memory Mgmt & Virtual Memory
45
First-fit algorithm ◦ Scans memory from the beginning and chooses the first available block that is large enough
◦ Fastest
Memory Mgmt & Virtual Memory
46
Next-fit ◦ Scans memory from the location of the last placement ◦ More often allocate a block of memory at the end of memory where the largest block is found ◦ The largest block of memory is broken up into smaller blocks ◦ Compaction is required to obtain a large block at the end of memory
Memory Mgmt & Virtual Memory
47
Figure 10 Example memory configuration before & after allocation of 16 MB block Memory Mgmt & Virtual Memory
48
Entire space available is treated as a single block of 2U