Lecture Topics: 11/20 HW 7 What happens on a memory reference Traps

Slides:



Advertisements
Similar presentations
More on File Management
Advertisements

Chapter 4 : File Systems What is a file system?
Operating Systems Lecture 10 Issues in Paging and Virtual Memory Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
Memory Design Example. Selecting Memory Chip Selecting SRAM Memory Chip.
Operating System Support Focus on Architecture
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
Computer Organization and Architecture
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Secondary Storage Management Hank Levy. 8/7/20152 Secondary Storage • Secondary Storage is usually: –anything outside of “primary memory” –storage that.
File Systems (1). Readings r Silbershatz et al: 10.1,10.2,
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
Cosc 2150: Computer Organization Chapter 6, Part 2 Virtual Memory.
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
NETW3005 File System Interface. Reading For this lecture, you should have read Chapter 10 (Sections 1-5) and Chapter 11 (Sections 1-4). NETW3005 (Operating.
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
Lecture Topics: 11/17 Page tables TLBs Virtual memory flat page tables
Virtual Memory Expanding Memory Multiple Concurrent Processes.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
I MPLEMENTING FILES. Contiguous Allocation:  The simplest allocation scheme is to store each file as a contiguous run of disk blocks (a 50-KB file would.
Lecture Topics: 11/29 File System Interface –Files and Directories –Access Methods –Protection –Consistency.
Lecture Topics: 12/1 File System Implementation –Space allocation –Free Space –Directory implementation –Caching Disk Scheduling File System/Disk Interaction.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
Computer Architecture Lecture 12: Virtual Memory I
Non Contiguous Memory Allocation
Chapter 2 Memory and process management
UNIT–IV: Memory Management
CS703 - Advanced Operating Systems
Modeling Page Replacement Algorithms
Chapter 11: File System Implementation
William Stallings Computer Organization and Architecture
Morgan Kaufmann Publishers
CS510 Operating System Foundations
Review.
Chapter 8: Main Memory.
Lecture 28: Virtual Memory-Address Translation
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
Chapter 11: File System Implementation
Chapter 9: Virtual-Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
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.
Chapter 11: File System Implementation
Computer-System Architecture
Module 2: Computer-System Structures
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
So far… Text RO …. printf() RW link printf Linking, loading
Main Memory Background Swapping Contiguous Allocation Paging
CS399 New Beginnings Jonathan Walpole.
Modeling Page Replacement Algorithms
Chapter 8: Memory management
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
Secondary Storage Management Brian Bershad
Translation Buffers (TLB’s)
Operating Systems Lecture 3.
Module 2: Computer-System Structures
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
Translation Buffers (TLB’s)
Computer Architecture
Secondary Storage Management Hank Levy
Chapter 11: File System Implementation
Module 2: Computer-System Structures
Translation Buffers (TLBs)
Module 2: Computer-System Structures
COMP755 Advanced Operating Systems
Virtual Memory.
Review What are the advantages/disadvantages of pages versus segments?
Virtual Memory.
CSE 542: Operating Systems
Presentation transcript:

Lecture Topics: 11/20 HW 7 What happens on a memory reference Traps File systems

HW 7 Comments virtual address -> VPN If you can’t get a miss rate below 1% then find the lowest possible miss rate (i.e. the miss rate with maximum memory) all of the misses are compulsory misses Add 1% to whatever this miss rate is and find the minimum memory size that yields this miss rate For example, if the smallest possible miss rate is 2.3%, then find the minimum amount of memory that yields a miss rate of 3.3%. Your answers don’t have to be identical to the sample solutions, but they should be close

Virtual Address -> VPN

Working Set The working set of a process is the set of pages that it is actually using usually much smaller than the amount of memory that is allocated As long as a process's working set fits in memory it won't thrash Formally: the set of pages a job has referenced in the last T seconds How do we pick T? too big => could run more programs too small => thrashing

What happens on a memory reference? An instruction refers to memory location X: Is X's VPN in the TLB? Yes: get data from cache or memory. Done. (Often don't look in TLB if data is in the L1 cache) Trap to OS to load X's VPN into the cache OS: Is X's VP located in physical memory? Yes: replace TLB entry with X's VPN. Return control to CPU, which restarts the instruction. Done. Must load X's VP from disk pick a page to replace, write it back to disk if dirty load X's VP from disk into physical memory Replace the TLB entry with X's VPN. Return control to CPU, which restarts the instruction.

Traps A trap is an exception generated by the CPU Traps are caused by errors (divide by 0, invalid memory access) system call (i.e. a user request for the OS to do something) When a trap occurs, the CPU transfers control to the operating system A vector stores which OS service routine to use for each trap one routine for system calls one routine for handling page faults Trap number chooses the vector entry to use

What happens on a Trap? CPU switches protection mode from user to kernel (aka privileged or supervisor mode) Jumps to the specific trap handler like an interrupt service routine The trap handler saves the CPU state (registers etc.) sees what it needs to do does what it needs to do restores user state returns the the user program (switches back to user mode)

Files A user-level abstraction for “a collection of bytes in (non-volatile) storage” Files have: A name Possibly a type A location - which device, where on that device Size (and possibly maximum size) Protection - who may read and write this? Time, date, and user identification

File operations What operations should a file system support?

File Operations File creation Writing a file make room for the file enter the new file into the directory Writing a file specify the file and the data to write to the file OS keeps track of your location in the file successive writes are placed one after the other in the file

More File Operations Reading a file Repositioning within a file specify the file and the buffer into which the data should be read OS keeps track of your location in the file Location pointer is often shared between read and write operations Repositioning within a file Changes the location pointer Often called “seeking” No actual I/O

Yet More File Operations Deleting a file Find the directory entry and delete it Mark the space used by the file as free Don’t actually “erase” the file Truncating a file Throw away all the data in the file Keep the attribute information

Opening and Closing Files The above six operations are enough But for convenience, we have the notion of the open file The open system call tells the OS that the specified file will be used by several operations user need not specify name each time OS need not search directories each time Location pointers, etc. need only be maintained for open files

Directories The directory lists all of the files in the volume A volume is a logical disk - there may be more than one volume per physical disk (or more than one physical disk per volume) We put the directory at the beginning so we always know where to start Directory Files Volume

Single-Level Directories In a single-level directory structure, the directory lists all files and their offsets Like a table of contents notes410 5 Spring00 12 todo 55 ideas 59 notes410 Spring00 todo ideas

Two-Level Directories Single-level directories suffer from name collision If you and I both name a file “prog1.c” then one file will overwrite the other Split up the space into top-level directories for each user Keep a directory for each user’s files, and a directory of the user directories

Tree-Structured Directories Let directories contain subdirectories Arrange files in a tree To name a file, specify a list of directories from the top down, plus the name of the file itself This is called a path name A path beginning at the root is an absolute path; if part of the path is implied, it’s a relative path

The Current Directory Set the current directory with setcwd() system call All future open() calls interpret path names relative to the current directory Saves on directory lookups Initial current directory is often set at login time, to the user’s home directory

Disk Block Allocation The basic unit of storage on a disk is a block Block sizes vary, but think 512 bytes Each file is stored in one or more blocks For simplicity, blocks are not split between files; leftover space at the end of a block is wasted When creating or enlarging a file, which disk block(s) should be allocated to the file?

Contiguous Allocation In contiguous allocation, a file gets blocks b, b+1, b+2, ... Direntry stores starting location, length Two blocks with sequential numbers are very likely to be in the same track, so no head movement is required What’s the problem?

Linked allocation In linked allocation, a file gets a linked list of disk blocks Direntry stores starting location Each block contains data and a pointer to the next block Advantages? Disadvantages?

Indexed allocation In indexed allocation, the file gets a list of disk blocks An index block contains the block list Advantages Disadvantages How do we deal with very large files?

other file information Unix Inodes data other file information data data direct blocks data data data 1 indirect data data 2 indirects data 3 indirects data

Free Space How do you find free disk blocks? Bitmap: One long string of bits represents the disk, one bit per block Linked list: each free block points to the next one (slow!) Grouping: list free blocks in the first free block Counting: keep a list of streaks of free blocks and their lengths