Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 121 Today’s class Operating System Machine Level.

Slides:



Advertisements
Similar presentations
Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
Advertisements

MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 3 Memory Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Memory/Storage Architecture Lab Computer Architecture Virtual Memory.
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
Virtual Memory Chapter 8.
Memory Management (II)
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Lecture 11: Memory Management
Memory Management 2010.
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Virtual Memory Chapter 8.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Chapter 3.2 : Virtual Memory
1 Lecture 9: Virtual Memory Operating System I Spring 2007.
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved The Operating System Machine.
Virtual Memory Management B.Ramamurthy. Paging (2) The relation between virtual addresses and physical memory addres- ses given by page table.
03/22/2004CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
1 Virtual Memory Management B.Ramamurthy Chapter 10.
Chapter 91 Translation Lookaside Buffer (described later with virtual memory) Frame.
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
Virtual Memory  Early computers had a small and fixed amount to memory. All programs had to be able to fit in this memory. Overlays were used when the.
Operating System Machine Level  An operating system is a program that, from the programmer’s point of view, adds a variety of new instructions and features,
VIRTUAL MEMORY. Virtual memory technique is used to extents the size of physical memory When a program does not completely fit into the main memory, it.
CSE378 Virtual memory.1 Evolution in memory management techniques In early days, single program ran on the whole machine –used all the memory available.
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
General System Architecture and I/O.  I/O devices and the CPU can execute concurrently.  Each device controller is in charge of a particular device.
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
1 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
8.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Implementation of Page Table Page table is kept in main memory Page-table base.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
CE Operating Systems Lecture 14 Memory management.
Operating Systems (CS 340 D) Princess Nora University Faculty of Computer & Information Systems Computer science Department.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Swap Space and Other Memory Management Issues Operating Systems: Internals and Design Principles.
Informationsteknologi Wednesday, October 3, 2007Computer Systems/Operating Systems - Class 121 Today’s class Memory management Virtual memory.
操作系统原理 OPERATING SYSTEM Chapter 3 Memory Management 内存管理.
Page Replacement Implementation Issues Text: –Tanenbaum ch. 4.7.
1 Lecture 8: Virtual Memory Operating System Fall 2006.
CS203 – Advanced Computer Architecture Virtual Memory.
1 Contents Memory types & memory hierarchy Virtual memory (VM) Page replacement algorithms in case of VM.
Memory Management Chapter 3
Memory Management.
CE 454 Computer Architecture
Memory Management Paging (continued) Segmentation
Session 3 Memory Management
Paging COMP 755.
ITEC 202 Operating Systems
COMBINED PAGING AND SEGMENTATION
Page Replacement Implementation Issues
Lecture 10: Virtual Memory
Paging and Segmentation
Lecture 28: Virtual Memory-Address Translation
Operating System Concepts
Chapter 9: Virtual-Memory Management
Memory Management Paging (continued) Segmentation
MICROPROCESSOR MEMORY ORGANIZATION
The Operating System Machine Level
Page Replacement Implementation Issues
Computer Architecture
Evolution in memory management techniques
Evolution in memory management techniques
Evolution in memory management techniques
Memory Management Paging (continued) Segmentation
COMP755 Advanced Operating Systems
Presentation transcript:

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 121 Today’s class Operating System Machine Level

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 122 Operating System Machine

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 123 Paging A mapping in which virtual addresses 4096 to 8191 are mapped onto main memory addresses 0 to 4095.

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 124 Implementation of Paging Virtual address space divided into a number of equal-sized pages Main memory is divided the same way This figure shows 4KB pages for the first 64KB of virtual memory

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 125 Implementation of Paging Physical memory is divided into page frames, each frame capable of holding one page of virtual memory This shows 32KB of physical memory divided into 4KB page frames

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 126 Implementation of Paging Memory Management Unit handles translation of virtual address to physical address

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 127 Demand Paging Not all virtual pages will be in main memory at the same time When a reference is made to a virtual page that is not in main memory you generate a page fault The operating system must retrieve the desired page from disk and place it in physical memory

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 128 Working Set The set of pages that a program is actively and heavily using is called the working set Ideally want the working set kept in main memory to reduce page faults

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 129 Page Replacement Policy When a page fault is generated a page of virtual memory must be brought into main memory If main memory is full a page from main memory must be written back to disk (if it was changed) or otherwise removed to make room for the new page How the page to remove is chosen is known as the page replacement policy

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1210 Least Recently Used (LRU) Remove the page from memory that was used the longest ago Works well if the working set fits in main memory If it doesn’t, bad things can happen, as shown here: the working set contains a loop that covers 9 pages of memory, but room for only 8 in physical memory

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1211 First-In, First-Out (FIFO) Removes the page loaded into memory longest ago, independent of when it was last referenced.

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1212 Segments Some software products generate many tables that grow and shrink in size during program execution Compilers are notorious for this Segments provide a way to provide completely independent address spaces

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1213 Segmented Memory Allows each table to grow or shrink independently of the other tables.

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1214 Comparison of Paging and Segmentation

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1215 External Fragmentation

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1216 Segmentation with Paging

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1217 Virtual Memory on the Pentium 4 Sophisticated! Supports:  Demand paging  Pure segmentation  Segmentation with paging Two tables:  LDT (Local Descriptor Table), one for each program  GDT (Global Descriptor Table), shared by all programs

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1218 Pentium 4 Selector Used for accessing a segment The 13-bit index specifies the LDT or GDT entry number, so each table can have at most 8 KB segment descriptors

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1219 Pentium 4 Code Segment Descriptor 8 bytes Includes segment’s base address, size, and other information

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1220 Obtaining a Linear Address If paging is disabled, the linear address is interpreted as the physical address If paging is enabled, the linear address is interpreted as a virtual address

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1221 Protection on the Pentium 4

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1222 Virtual I/O Instructions I/O is one area where OSM and ISA levels differ considerably User does not want to deal with the complexities of device register interactions One way of organizing the virtual I/O is to use an abstraction called a file

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1223 Files To the operating system a file is normally just a sequence of bytes  However, some operating systems can organize a file into a sequence of logical records Any further structure is up to the application programs I/O is done by system calls for opening, reading, writing, and closing files

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1224 Disk Allocation Strategies A file in consecutive sectors. A file not in consecutive sectors.

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1225 Keeping Track of Available Sectors Free list Bit map

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1226 Directories Organize files on disk A user file directory and the contents of a typical entry in a file directory are shown at the right

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1227 Parallel Processing True parallel processing Parallel processing simulated by switching with multiple CPUs one CPU among three processes

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1228 Processes A program runs as part of a process Processes can be created and terminated dynamically To achieve parallel processing a system call to create a process is needed Created process can:  Exist in a parent/child relationship with creating process  Run completely independently of creating process

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1229 Communication Parallel processes need to communicate and synchronize with each other to get their work done As an example, two processes can communicate via a shared memory buffer Consider process 1 the producer, which puts data values into the buffer Consider process 2 the consumer, which takes data values out of the buffer

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1230 Synchronization The two processes run in parallel at different rates If the producer discovers the buffer is full it suspends itself until a signal from the consumer tells it there is room in the buffer If the consumer discovers the buffer is empty it suspends itself until a signal from the producer that there is a number in the buffer

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1231 Circular Buffer

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1232 Race Condition Suppose only one number left in buffer at location 21 (in = 22 and out = 21) Now suppose the consumer takes this number out, changing out to 22 Suppose the consumer continues, and gets to the point where it fetches in and out getting ready to compare them to see if they are equal (indicating an empty buffer) After the fetch, but before the comparison, the producer puts the next number into the buffer and increments in to 23

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1233 Race Condition It now recognizes there is only one number in the buffer so sends a signal to the consumer to wake up; the consumer is awake so the signal is lost Now the consumer goes back to work and thinks the buffer is empty (in = out) and goes to sleep Now the producer puts another number in the buffer, but since it sees two numbers in the buffer it (incorrectly) assumes the consumer is awake

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1234 Race Condition Producer continues running and eventually fills the buffer; when it does so it will go to sleep Consumer is asleep and never gets a signal to wake up Both processes are sleeping and will remain so forever This came about because of a race condition, because it was a race to see who modified in or out first

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1235 Semaphores Non-negative integer variables that solve the communication problem between parallel processes

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1236 Windows XP

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1237 Windows XP Virtual Memory Each process has its own virtual address space Virtual addresses are 32 bits long, so there’s a 4 GB virtual address space The lower 2 GB are available for the process’ code and data The upper 2 GB allow limited access to kernel memory

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1238 Windows XP Virtual I/O XP supports several file systems, but the one of most interest is NTFS (NT File System) Unicode is used throughout XP File names can be up to 255 characters A file is just a linear sequence of bytes, up to a maximum of bytes

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1239 Principal Win32 API Functions for File I/O

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1240 Principal Win32 API Functions for Directory Work

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1241 Windows XP Master File Table

Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 1242 Windows XP Process Management XP supports multiple processes Processes can communicate and synchronize No enforcement of parent-child or other hierarchy – all processes are created equal