CSE 351 Final Exam Review 1. The final exam will be comprehensive, but more heavily weighted towards material after the midterm We will do a few problems.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

SE-292: High Performance Computing
Part IV: Memory Management
1 Memory hierarchy and paging Electronic Computers M.
OS Fall’02 Virtual Memory Operating Systems Fall 2002.
Paging Hardware With TLB
Recap. The Memory Hierarchy Increasing distance from the processor in access time L1$ L2$ Main Memory Secondary Memory Processor (Relative) size of the.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Memory Management.
Translation Buffers (TLB’s)
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
Memory: Virtual MemoryCSCE430/830 Memory Hierarchy: Virtual Memory CSCE430/830 Computer Architecture Lecturer: Prof. Hong Jiang Courtesy of Yifeng Zhu.
03/22/2004CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
A. Frank - P. Weisberg Operating Systems Simple/Basic Paging.
CS 61C: Great Ideas in Computer Architecture
Mem. Hier. CSE 471 Aut 011 Evolution in Memory Management Techniques In early days, single program run on the whole machine –Used all the memory available.
Main Memory. Background Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are only.
03/17/2008CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Chapter 8: Main Memory.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 346, Royden, Operating System Concepts Operating Systems Lecture 24 Paging.
Operating System Chapter 7. Memory Management Lynn Choi School of Electrical Engineering.
CS333 Intro to Operating Systems Jonathan Walpole.
Lecture 21 Last lecture Today’s lecture Cache Memory Virtual memory
Computer Architecture Lecture 28 Fasih ur Rehman.
CS 153 Design of Operating Systems Spring 2015 Lecture 17: Paging.
CSE431 L22 TLBs.1Irwin, PSU, 2005 CSE 431 Computer Architecture Fall 2005 Lecture 22. Virtual Memory Hardware Support Mary Jane Irwin (
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.
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
Lecture Topics: 11/17 Page tables TLBs Virtual memory flat page tables
8.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Paging Physical address space of a process can be noncontiguous Avoids.
1 Virtual Memory and Address Translation. 2 Review Program addresses are virtual addresses.  Relative offset of program regions can not change during.
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 Memory Management (b). 2 Paging  Logical address space of a process can be noncontiguous; process is allocated physical memory whenever the latter.
CSE 351 Virtual Memory. Agenda Today … Review on VM Example problems on VM accesses.
Operating Systems Lecture 14 Segments Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software Engineering.
9.1 Operating System Concepts Paging Example. 9.2 Operating System Concepts.
Virtual Memory Additional Slides Slide Source: Topics Address translation Accelerating translation with TLBs class12.ppt.
Operating Systems Unit 7: – Virtual Memory organization Operating Systems.
Paging (continued) & Caching CS-3013 A-term Paging (continued) & Caching CS-3013 Operating Systems A-term 2008 (Slides include materials from Modern.
4.3 Virtual Memory. Virtual memory  Want to run programs (code+stack+data) larger than available memory.  Overlays programmer divides program into pieces.
Lab4: Virtual Memory CS 3410 : Computer System Organization & Programming Spring 2015.
Virtual Memory Review Goal: give illusion of a large memory Allow many processes to share single memory Strategy Break physical memory up into blocks (pages)
Memory Management Continued Questions answered in this lecture: What is paging? How can segmentation and paging be combined? How can one speed up address.
8.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Fragmentation External Fragmentation – total memory space exists to satisfy.
LECTURE 12 Virtual Memory. VIRTUAL MEMORY Just as a cache can provide fast, easy access to recently-used code and data, main memory acts as a “cache”
Operating Systems Session 7: – Virtual Memory organization Operating Systems.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
University of Washington Indirection in Virtual Memory 1 Each process gets its own private virtual address space Solves the previous problems Physical.
Chapter 7: Main Memory CS 170, Fall Program Execution & Memory Management Program execution Swapping Contiguous Memory Allocation Paging Structure.
CSE 351 Caches. Before we start… A lot of people confused lea and mov on the midterm Totally understandable, but it’s important to make the distinction.
W4118 Operating Systems Instructor: Junfeng Yang.
Vivek Seshadri 15740/18740 Computer Architecture
Virtual Memory Acknowledgment
Virtualization Virtualize hardware resources through abstraction CPU
Memory COMPUTER ARCHITECTURE
Outline Paging Swapping and demand paging Virtual memory.
Today How was the midterm review? Lab4 due today.
Paging and Segmentation
CSCI206 - Computer Organization & Programming
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
CS 105 “Tour of the Black Holes of Computing!”
CSS 430: Operating Systems - Main Memory
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE451 Virtual Memory Paging Autumn 2002
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CS 105 “Tour of the Black Holes of Computing!”
CS 105 “Tour of the Black Holes of Computing!”
Presentation transcript:

CSE 351 Final Exam Review 1

The final exam will be comprehensive, but more heavily weighted towards material after the midterm We will do a few problems from previous years’ finals together as a class PLEASE ask questions if you get lost! 2

Quiz We have another quiz we want to spend a few minutes on 3

Quiz 1. A 4-byte integer can be moved into a 32-bit register using a movw instruction. ☐ True  False 2. On a 64-bit architecture, casting a C integer to a double does not lose precision.  True ☐ False 3. Shifting an int by 3 bits to the left (<< 3) is the same as multiplying it by 8.  True ☐ False 4. In C, endianess makes a difference in how character strings (char*) are stored. ☐ True  False 5. In C, storing multi-dimensional arrays in row major order makes it possible for pointer arithmetic to determine the address of an array element.  True ☐ False 6. A struct can’t have internal fragmentation if the elements of the struct are ordered from largest to smallest.  True ☐ False 7. An instruction cache takes advantage of only spatial locality. ☐ True  False 8. Caches are part of the instruction set architecture (ISA) of a computer. ☐ True  False 4

Quiz 9. Caches make computers slower by getting between the CPU and memory. ☐ True  False 10. On a 64-bit architecture, if a cache block is 32 bytes, and there are 256 sets in the cache, the tag will be 53 bits. ☐ True  False 11. A process’s instructions are typically in a read-only segment of memory.  True ☐ False 12. A shared library can be accessed from multiple virtual address spaces, but with only one copy in physical memory.  True ☐ False 13. Virtual memory allows programs to act as if there is more physical memory than there actually exists on the computer.  True ☐ False 14. Two running instances of the same process share the same memory address space. ☐ True  False 15. Java generally has better performance than C. ☐ True  False 5

Stacks and Structs Definition of a print_struct function: void print_struct(data_struct *y) { printf("%p\n", y); printf("%d\n", *(y->b + y->c)); > } 6 The program includes the definition for a data_structure type: typedef struct data_struct { int a; int *b; int c; } data_struct; This is a small snippet of code corresponding to foo, which has just been called and in turns calls print_struct: int foo() { data_struct x; int n = 13; x.a = ???; x.b = &n; x.c = 3; print_struct(&x); }

Stacks and Structs 7 Execution is suspended after the printf statements in print_struct but before it returns to foo. The stack at this point of the execution of the program is shown below in 4-byte blocks Note that the stack is shown as is tradition, from bottom to top, with the top-most of the stack at the bottom or lowest address: 0x7fffffffffffa040: 0x x7fffffffffffa03c: 0x x7fffffffffffa038: 0x f 0x7fffffffffffa034: 0x x7fffffffffffa030: 0x x7fffffffffffa02c: 0x x7fffffffffffa028: 0x x7fffffffffffa024: 0x7fffffff 0x7fffffffffffa020: 0xffffa014 0x7fffffffffffa01c: 0x x7fffffffffffa018: 0x x7fffffffffffa014: 0x d 0x7fffffffffffa010: 0x x7fffffffffffa00c: 0x

Stacks and Structs What is the value stored in the stack at the 8-bytes starting at location 0x7fffffffffffa00c to 0x7fffffffffffa013 and what does it represent? 8 Execution is suspended after the printf statements in print_struct but before it returns to foo. The stack at this point of the execution of the program is shown below in 4-byte blocks Note that the stack is shown as is tradition, from bottom to top, with the top-most of the stack at the bottom or lowest address: 0x7fffffffffffa040: 0x x7fffffffffffa03c: 0x x7fffffffffffa038: 0x f 0x7fffffffffffa034: 0x x7fffffffffffa030: 0x x7fffffffffffa02c: 0x x7fffffffffffa028: 0x x7fffffffffffa024: 0x7fffffff 0x7fffffffffffa020: 0xffffa014 0x7fffffffffffa01c: 0x x7fffffffffffa018: 0x x7fffffffffffa014: 0x d 0x7fffffffffffa010: 0x x7fffffffffffa00c: 0x

Stacks and Structs What is the value stored in the stack at the 8-bytes starting at location 0x7fffffffffffa00c to 0x7fffffffffffa013 and what does it represent? 0x which represents the return address to be used when print_struct returns to foo. Remember endian-ness! 9 Execution is suspended after the printf statements in print_struct but before it returns to foo. The stack at this point of the execution of the program is shown below in 4-byte blocks Note that the stack is shown as is tradition, from bottom to top, with the top-most of the stack at the bottom or lowest address: 0x7fffffffffffa040: 0x x7fffffffffffa03c: 0x x7fffffffffffa038: 0x f 0x7fffffffffffa034: 0x x7fffffffffffa030: 0x x7fffffffffffa02c: 0x x7fffffffffffa028: 0x x7fffffffffffa024: 0x7fffffff 0x7fffffffffffa020: 0xffffa014 0x7fffffffffffa01c: 0x x7fffffffffffa018: 0x x7fffffffffffa014: 0x d 0x7fffffffffffa010: 0x x7fffffffffffa00c: 0x << high order bytes of return address from print_struct << low order bytes of return address from print_struct

Stacks and Structs What value was assigned to x.a in the function foo and at what address is it stored on the stack? 10 Execution is suspended after the printf statements in print_struct but before it returns to foo. The stack at this point of the execution of the program is shown below in 4-byte blocks Note that the stack is shown as is tradition, from bottom to top, with the top-most of the stack at the bottom or lowest address: 0x7fffffffffffa040: 0x x7fffffffffffa03c: 0x x7fffffffffffa038: 0x f 0x7fffffffffffa034: 0x x7fffffffffffa030: 0x x7fffffffffffa02c: 0x x7fffffffffffa028: 0x x7fffffffffffa024: 0x7fffffff 0x7fffffffffffa020: 0xffffa014 0x7fffffffffffa01c: 0x x7fffffffffffa018: 0x x7fffffffffffa014: 0x d 0x7fffffffffffa010: 0x x7fffffffffffa00c: 0x

Stacks and Structs What value was assigned to x.a in the function foo and at what address is it stored on the stack? The value 0x7 represents x.a and is stored at location 0x7fffffffffffa Execution is suspended after the printf statements in print_struct but before it returns to foo. The stack at this point of the execution of the program is shown below in 4-byte blocks Note that the stack is shown as is tradition, from bottom to top, with the top-most of the stack at the bottom or lowest address: 0x7fffffffffffa040: 0x x7fffffffffffa03c: 0x x7fffffffffffa038: 0x f 0x7fffffffffffa034: 0x x7fffffffffffa030: 0x x7fffffffffffa02c: 0x x7fffffffffffa028: 0x x7fffffffffffa024: 0x7fffffff 0x7fffffffffffa020: 0xffffa014 0x7fffffffffffa01c: 0x x7fffffffffffa018: 0x x7fffffffffffa014: 0x d 0x7fffffffffffa010: 0x x7fffffffffffa00c: 0x << padding (external fragmentation), offset +20 << x.c, offset +16 << high order bytes of x.b << low order bytes of x.b, offset +8 << padding (internal fragmentation) << x.a, offset +0 << int n = 13

Structs 12 typedef struct data_struct { int a; int *b; int c; } data_struct; Take a look at struct_test.c

Processes 13 List the two important illusions that the process abstraction provides to programs. For each illusion, list a mechanism involved in its implementation.

Processes 14 List the two important illusions that the process abstraction provides to programs. For each illusion, list a mechanism involved in its implementation. 1. Logical control flow: the process executes as if it has complete control over the CPU. The OS implements this by interleaving execution of different processes via context-switching(exceptional control flow...). 2. Private linear address space: the process executes as if it has access to a private contiguous memory the size of the virtual address space.

Virtual Memory 15 One purpose of virtual memory is to allow programs to use more memory than is available in the physical memory, by storing some parts on disk transparently. Name some other useful thing that can be done with the virtual memory system.

Virtual Memory 16 One purpose of virtual memory is to allow programs to use more memory than is available in the physical memory, by storing some parts on disk transparently. Name some other useful things that can be done with the virtual memory system. 1. Sharing of a single physical page in multiple virtual address spaces (e.g., shared library code). 2. Memory protection mechanisms (e.g., page-granular read/write/execute permissions or protecting one process’s memory from another).

TLBs Does a TLB (Translation Lookaside Buffer) miss always lead to a page fault? Why or why not? 17

TLBs Does a TLB (Translation Lookaside Buffer) miss always lead to a page fault? Why or why not? No. The TLB caches page table entries. After a TLB miss, we do an in-memory page table lookup. A page fault occurs if the page table entry is invalid. 18

Java vs C Name some differences between Java references and C pointers. 19

Java vs C Name some differences between Java references and C pointers. 1. C allows pointer arithmetic; Java does not. 2. C pointers may point anywhere (including the middles of memory objects); Java references point only to the start of objects. 3. C pointers may be cast arbitrarily (even to non-pointer types); casts of Java references are checked to make sure they are type-safe. 20