Discussion Week 7 TA: Kyle Dewey. Overview Midterm debriefing Virtual memory Virtual Filesystems / Disk I/O Project #3.

Slides:



Advertisements
Similar presentations
Chapter 4 Memory Management Basic memory management Swapping
Advertisements

Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
Chapter 4 Memory Management Page Replacement 补充:什么叫页面抖动?
1 Memory hierarchy and paging Electronic Computers M.
Operating Systems Lecture 10 Issues in Paging and Virtual Memory Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing.
Virtual Memory Management G. Anuradha Ref:- Galvin.
Operating Systems ECE344 Ding Yuan Final Review Lecture 13: Final Review.
Virtual Memory Introduction to Operating Systems: Module 9.
CS 153 Design of Operating Systems Spring 2015
Virtual Memory Management
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Memory Management (II)
Lecture 11: Memory Management
Memory Management and Paging CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
1 Virtual Memory vs. Physical Memory So far, all of a job’s virtual address space must be in physical memory However, many parts of programs are never.
Understanding Operating Systems1 Operating Systems Virtual Memory Thrashing Single-User Contiguous Scheme Fixed Partitions Dynamic Partitions.
CS 104 Introduction to Computer Science and Graphics Problems
Virtual Memory Management B.Ramamurthy. Paging (2) The relation between virtual addresses and physical memory addres- ses given by page table.
1 Virtual Memory Management B.Ramamurthy Chapter 10.
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
Virtual Memory.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory.
Page 19/17/2015 CSE 30341: Operating Systems Principles Optimal Algorithm  Replace page that will not be used for longest period of time  Used for measuring.
CS 153 Design of Operating Systems Spring 2015 Lecture 17: Paging.
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
OSes: 11. FS Impl. 1 Operating Systems v Objectives –discuss file storage and access on secondary storage (a hard disk) Certificate Program in Software.
Computer Studies (AL) Memory Management Virtual Memory I.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 9: Virtual Memory.
1 Memory Management. 2 Fixed Partitions Legend Free Space 0k 4k 16k 64k 128k Internal fragmentation (cannot be reallocated) Divide memory into n (possible.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Demand Paging.
Virtual Memory Various memory management techniques have been discussed. All these strategies have the same goal: to keep many processes in memory simultaneously.
1 Virtual Memory. Cache memory: provides illusion of very high speed Virtual memory: provides illusion of very large size Main memory: reasonable cost,
11.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles 11.5 Free-Space Management Bit vector (n blocks) … 012n-1 bit[i] =  1  block[i]
Virtual Memory Questions answered in this lecture: How to run process when not enough physical memory? When should a page be moved from disk to memory?
Memory Management OS Fazal Rehman Shamil. swapping Swapping concept comes in terms of process scheduling. Swapping is basically implemented by Medium.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
10.1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples.
1 Contents Memory types & memory hierarchy Virtual memory (VM) Page replacement algorithms in case of VM.
Virtual Memory.
Virtual Memory Chapter 8.
SLC/VER1.0/OS CONCEPTS/OCT'99
Virtual Memory CSSE 332 Operating Systems
Chapter 2 Memory and process management
CS 6560: Operating Systems Design
Chapter 9: Virtual Memory – Part I
CS703 - Advanced Operating Systems
Chapter 9: Virtual Memory
Modeling Page Replacement Algorithms
Module 9: Virtual Memory
Chapter 8: Main Memory.
O.S Lecture 13 Virtual Memory.
Chapter 9: Virtual-Memory Management
Operating Systems Lecture November 2018.
Main Memory Background Swapping Contiguous Allocation Paging
Modeling Page Replacement Algorithms
Chapter 9: Virtual Memory
Chapter 4: Memory Management
CSE 451: Operating Systems Autumn 2005 Memory Management
Contents Memory types & memory hierarchy Virtual memory (VM)
CSE451 Virtual Memory Paging Autumn 2002
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Lecture Topics: 11/20 HW 7 What happens on a memory reference Traps
Chapter 8 & 9 Main Memory and Virtual Memory
CSE 542: Operating Systems
Module IV Memory Organization.
Presentation transcript:

Discussion Week 7 TA: Kyle Dewey

Overview Midterm debriefing Virtual memory Virtual Filesystems / Disk I/O Project #3

How was the midterm?

Recap Implemented a page table in Project #2 Provides a mechanism for virtualizing memory

Without Virtual Memory

P1 Enters Free Free Free Free Free Free Free Free Free Free P1 P1 Requests 2 Pages

P2 Enters Free Free Free Free P1 P1 P2 P2 Free Free P1 P1 Free Free Free Free P1 P1 Requests 2 Pages

P1 Exits Free Free Free Free P2 P2 Free Free Free Free Free Free P1 P1 P2 P2 Free Free P1 P1 Free Free 2 Pages Freed

P3 Enters Requests 3 Pages Free Free Free Free P2 P2 Free Free Free Free ???

Problem Not enough contiguous free memory to allocate request Plenty of free memory in total This is external fragmentation

VM Advantage Avoids external fragmentation Far more flexible

Paging Way to exploit virtual memory Idea: use memory as a cache for the whole disk Virtual memory makes this caching transparent to processes

Paging Details In an ideal world, each page has the following bits: Valid? Dirty? Referenced? NACHOS is an ideal world

Valid Bit Project #2: does this process have access to the given page? Modern OS / Project #3: is this page in memory and/or does this process have access to it?

Valid Bit Example

What of Permissions? Reference to page with invalid bit set traps to OS anyway More accurately, it’s a “Trap to OS on Use” bit Still need to check if caller can access page

Dirty Bit Consider the lifetime of a page Disk Used Free Free Free Used Used Used Used Disk Page Swapped In Page Swapped Out

Swapping Out What if a page is read-only? What if a page was never modified since being swapped in? In these cases, we end up paging out information that is the same as what is already on disk Complete waste!

Dirty Bit If a page is modified, the dirty bit is set (by hardware) Only write out if dirty bit is set Potentially cuts I/O on paging in half

Referenced Bit If a page is used, set the referenced bit (by hardware) Allow software to reset the bit Makes certain algorithms easier to implement

Question: Can kernel pages be paged out?

Project #3 Task I Implement paging with either FIFO with second chance or LRU Step-by-step implementation instructions included

Stages in Demand Paging 1. Trap to the operating system 2. Save the user registers and process state 3. Determine that the interrupt was a page fault 4. Check that the page reference was legal and determine the location of the page on the disk 5. Issue a read from the disk to a free frame: 1. Wait in a queue for this device until the read request is serviced 2. Wait for the device seek and/or latency time 3. Begin the transfer of the page to a free frame 6. While waiting, allocate the CPU to some other user 7. Receive an interrupt from the disk I/O subsystem (I/O completed) 8. Save the registers and process state for the other user 9. Determine that the interrupt was from the disk 10. Correct the page table and other tables to show page is now in memory 11. Wait for the CPU to be allocated to this process again 12. Restore the user registers, process state, and new page table, and then resume the interrupted instruction

Virtual Filesystems

Behold! ~]$ df -hFilesystem Size Used Avail Use% Mounted on/dev/sda6 26G 8.9G 16G 37% /tmpfs 4.0G 1.4M 4.0G 1% /dev/shm/dev/sda1 504M 68M 411M 15% /boot/dev/sda7 26G 2.7G 22G 12% /local/dev/sda3 4.0G 137M 3.7G 4% /tmp/dev/sda2 7.9G 1011M 6.5G 14% /varodin:/local/home/faculty 268G 171G 84G 68% /cs/facultyletters:/spool/mail 268G 62G 194G 25% /cs/mailfrigga:/local/home/student 268G 252G 3.3G 99% /cs/studentfrigga:/local/home/class 268G 252G 3.3G 99% /cs/classhal1.engr.ucsb.edu:/fs.real/hal1a/home 4.5T 1006G 3.3T 24% /fs/home1offside:/local/home 547G 451G 69G 87% ~]$ ls /csarch class faculty mail ~]$

Virtual Filesystem Puts underlying filesystems into a single, consistent view Object-oriented design at its best

Design Hierarchy open(), read()... (OS Specific) (FS specific )

Advantage Easy to extend to multiple filesystems LOTS of code sharing possible (caching, file management,...)

Storing Files Similar problems as with physical memory Differences: Access times are MUCH slower Much better performance if accessing contiguous blocks

F1 Written Free Free Free Free Free Free Free Free Free Free F1 F1 2 Bytes Long

F2 Written Free Free Free Free P1 P1 F2 F2 Free Free F1 F1 Free Free Free Free F1 F1 2 Bytes Long

F1 is Deleted Free Free Free Free F2 F2 Free Free Free Free Free Free P1 P1 F2 F2 Free Free F1 F1 Free Free 2 Bytes Freed

P3 Written 3 Bytes Written Free Free Free Free P2 P2 Free Free Free Free ???

Solution Indirection in much the same way as virtual memory This is what the File Allocation Table (FAT) filesystem is named for

FAT Separates disks into blocks Intuitively, blocks are to disk as pages are to memory The number afterward defines the number of bits used for an entry

FAT Block Next Block 0∞ ∞ 7 8∞ 98 Next Block ∞ ∞ ∞ 8 IntuitivelyActually Stored

Issues Fragile with respect to faults Worst case: entire FAT must be read for a single file seek() is actually O(n), where n is the number of blocks used in a file

Tradeoff Represent some blocks directly, others indirectly Make the whole file metadata fit into one block UNIX inodes usually do this

UNIX inode

Advantages For small files, only direct blocks are needed seek() will be O(1) Still can represent large files seek() will be either O(1) or O(n), depending how far into the file we are seeking

Relevance to NACHOS NACHOS has file size limitation of 4 Kb Need to extend to 100 Kb Will involve adding an indirect level on top of existing direct level

Project #3 Implementation Notes