Download presentation
Presentation is loading. Please wait.
1
Session 3 Memory Management
Hofstra University Fall 2008 Session 3 Memory Management Nassau Community College ITE153 – Operating Systems Fall 2011 1 Network Security Course, CSC288 DL1
2
Hofstra University Memory In The Operating System
Session 3 Fall 2008 Memory In The Operating System Nassau Community College ITE153 – Operating Systems Fall 2011 Network Security Course, CSC288 DL1
3
What Is An Operating System (1)
Hofstra University What Is An Operating System (1) Fall 2008 A modern computer consists of: One or more processors Main memory Disks Printers Various input/output devices Managing all these components requires a layer of software – the operating system Nassau Community College ITE153 – Operating Systems Fall 2011 Network Security Course, CSC288 DL1
4
What Is An Operating System (2)
Hofstra University What Is An Operating System (2) Fall 2008 Nassau Community College ITE153 – Operating Systems Fall 2011 Network Security Course, CSC288 DL1
5
Computer Hardware Review
Hofstra University Computer Hardware Review Fall 2008 Some of the components of a simple personal computer. Nassau Community College ITE153 – Operating Systems Fall 2011 Network Security Course, CSC288 DL1
6
Memory (1) A typical memory hierarchy. The numbers are very rough approximations. Nassau Community College ITE153 – Operating Systems Fall 2011
7
Nassau Community College ITE153 – Operating Systems
Memory (2) Questions when dealing with cache: When to put a new item into the cache. Which cache line to put the new item in. Which item to remove from the cache when a slot is needed. Where to put a newly evicted item in the larger memory. Nassau Community College ITE153 – Operating Systems Fall 2011
8
Hofstra University Memory Management
Session 3 Fall 2008 Memory Management Nassau Community College ITE153 – Operating Systems Fall 2011 Network Security Course, CSC288 DL1
9
Nassau Community College ITE153 – Operating Systems
No Memory Abstraction Three simple ways of organizing memory with an operating system and one user process. Nassau Community College ITE153 – Operating Systems Fall 2011
10
Multiple Programs Without Memory Abstraction
Illustration of the relocation problem. Nassau Community College ITE153 – Operating Systems Fall 2011
11
Nassau Community College ITE153 – Operating Systems
Base and Limit Registers Base and limit registers are used to give each process a separate address space. Nassau Community College ITE153 – Operating Systems Fall 2011
12
Nassau Community College ITE153 – Operating Systems
Swapping (1) Memory allocation changes as processes come into memory and leave it. The shaded regions are unused memory. Nassau Community College ITE153 – Operating Systems Fall 2011
13
Nassau Community College ITE153 – Operating Systems
Swapping (2) (a) Allocating space for growing data segment. (b) Allocating space for growing stack, growing data segment. Nassau Community College ITE153 – Operating Systems Fall 2011
14
Memory Management with Bitmaps
(a) A part of memory with five processes and three holes. The tick marks show the memory allocation units. The shaded regions (0 in the bitmap) are free. (b) The corresponding bitmap. (c) The same information as a list. Nassau Community College ITE153 – Operating Systems Fall 2011
15
Virtual Memory – Paging (1)
The position and function of the MMU – shown as being a part of the CPU chip (it commonly is nowadays). Logically it could be a separate chip, was in years gone by. Nassau Community College ITE153 – Operating Systems Fall 2011
16
Nassau Community College ITE153 – Operating Systems
Hofstra University Computing Folklore Fall 2008 Uncle Vito’s Motel Nassau Community College ITE153 – Operating Systems Fall 2011 Network Security Course, CSC288 DL1
17
Nassau Community College ITE153 – Operating Systems
Paging (2) Relation between virtual addresses and physical memory addresses given by page table. Nassau Community College ITE153 – Operating Systems Fall 2011
18
Nassau Community College ITE153 – Operating Systems
Paging (3) The internal operation of the MMU with 16 4-KB pages. Nassau Community College ITE153 – Operating Systems Fall 2011
19
Nassau Community College ITE153 – Operating Systems
Speeding Up Paging Paging implementation issues: The mapping from virtual address to physical address must be fast. If the virtual address space is large, the page table will be large. Nassau Community College ITE153 – Operating Systems Fall 2011
20
Page Replacement Algorithms
Optimal page replacement algorithm Not recently used page replacement First-In, First-Out page replacement Second chance page replacement Clock page replacement Least recently used page replacement Working set page replacement WSClock page replacement Nassau Community College ITE153 – Operating Systems Fall 2011
21
Working Set Page Replacement (1)
The working set is the set of pages used by the k most recent memory references. The function w(k, t) is the size of the working set at time t. Nassau Community College ITE153 – Operating Systems Fall 2011
22
Summary of Page Replacement Algorithms
Figure Page replacement algorithms discussed in the text. Nassau Community College ITE153 – Operating Systems Fall 2011
23
Separate Instruction and Data Spaces
(a) One address space. (b) Separate I and D spaces. Nassau Community College ITE153 – Operating Systems Fall 2011
24
Nassau Community College ITE153 – Operating Systems
Shared Pages Two processes sharing the same program sharing its page table. Nassau Community College ITE153 – Operating Systems Fall 2011
25
Shared Libraries A shared library being used by two processes.
Nassau Community College ITE153 – Operating Systems Fall 2011
26
Nassau Community College ITE153 – Operating Systems
Page Fault Handling (1) The hardware traps to the kernel, saving the program counter on the stack. An assembly code routine is started to save the general registers and other volatile information. The operating system discovers that a page fault has occurred, and tries to discover which virtual page is needed. Once the virtual address that caused the fault is known, the system checks to see if this address is valid and the protection consistent with the access Nassau Community College ITE153 – Operating Systems Fall 2011
27
Nassau Community College ITE153 – Operating Systems
Page Fault Handling (2) If the page frame selected is dirty, the page is scheduled for transfer to the disk, and a context switch takes place. When page frame is clean, operating system looks up the disk address where the needed page is, schedules a disk operation to bring it in. When disk interrupt indicates page has arrived, page tables updated to reflect position, frame marked as being in normal state. Nassau Community College ITE153 – Operating Systems Fall 2011
28
Nassau Community College ITE153 – Operating Systems
Page Fault Handling (3) Faulting instruction backed up to state it had when it began and program counter reset to point to that instruction. Faulting process scheduled, operating system returns to the (assembly language) routine that called it. This routine reloads registers and other state information and returns to user space to continue execution, as if no fault had occurred. Nassau Community College ITE153 – Operating Systems Fall 2011
29
Separation of Policy and Mechanism (1)
Memory management system is divided into three parts: A low-level MMU handler. A page fault handler that is part of the kernel. An external pager running in user space. Nassau Community College ITE153 – Operating Systems Fall 2011
30
Separation of Policy and Mechanism (2)
Page fault handling with an external pager. Nassau Community College ITE153 – Operating Systems Fall 2011
31
Nassau Community College ITE153 – Operating Systems
Segmentation (1) A compiler has many tables that are built up as compilation proceeds, possibly including: The source text being saved for the printed listing (on batch systems). The symbol table – the names and attributes of variables. The table containing integer, floating-point constants used. The parse tree, the syntactic analysis of the program. The stack used for procedure calls within the compiler. Nassau Community College ITE153 – Operating Systems Fall 2011
32
Nassau Community College ITE153 – Operating Systems
Segmentation (2) In a one-dimensional address space with growing tables, one table may bump into another. Nassau Community College ITE153 – Operating Systems Fall 2011
33
Nassau Community College ITE153 – Operating Systems
Segmentation (3) A segmented memory allows each table to grow or shrink independently of the other tables. Nassau Community College ITE153 – Operating Systems Fall 2011
34
Implementation of Pure Segmentation
Comparison of paging and segmentation. Nassau Community College ITE153 – Operating Systems Fall 2011
35
Segmentation with Paging: The Pentium (5)
Protection on the Pentium. Nassau Community College ITE153 – Operating Systems Fall 2011
36
<ALT><CTRL><DEL>
Hofstra University <ALT><CTRL><DEL> Fall 2008 Try <ALT><CTRL><DEL> to get into Task Manager Nassau Community College ITE153 – Operating Systems Fall 2011 Network Security Course, CSC288 DL1
37
Nassau Community College ITE153 – Operating Systems
Hofstra University Fall 2008 Important URLs Memory Management This is from the Microsoft point of view Memory Management Linux Another point of view Peter Denning Create Virtual Memory in 1970 Here are some useful URLs… Nassau Community College ITE153 – Operating Systems Fall 2011 37 Network Security Course, CSC288 DL1 37
38
Nassau Community College ITE153 – Operating Systems
Hofstra University Homework Fall 2008 Review the Slides Keep Practicing Commands Try <ALT><CTRL><DEL> to get into Task Manager Read Section in the Text – Monitoring System Performance Nassau Community College ITE153 – Operating Systems Fall 2011 Network Security Course, CSC288 DL1
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.