This is an open book, open notes exam. But no online or in-class chatting.

Similar documents
This is an open book, open notes exam. But no online or in-class chatting.

This is an open book, open notes exam. But no online or in-class chatting.

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Quiz I

ICS143A: Principles of Operating Systems. Midterm recap, sample questions. Anton Burtsev February, 2017

This is an open book, open notes exam. But no online or in-class chatting.

This is an open book, open notes exam. But no online or in-class chatting.

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Quiz I Solutions. Mean 70.5 Median 72 Standard deviation 15.8 Kurtosis -0.

Quiz I Solutions MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Department of Electrical Engineering and Computer Science

CS5460/6460: Operating Systems. Lecture 9: Finishing system boot, and system init. Anton Burtsev January, 2014

238P: Operating Systems. Lecture 9: Creating Processes. Anton Burtsev February, 2018

6.828: Using Virtual Memory. Adam Belay

143A: Principles of Operating Systems. Lecture 7: System boot. Anton Burtsev January, 2017

Quiz I Solutions MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Department of Electrical Engineering and Computer Science

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Quiz I

CS3210: Virtual memory applications. Taesoo Kim

143A: Principles of Operating Systems. Lecture 09: First process. Anton Burtsev January, 2017

238P: Operating Systems. Lecture 7: System boot. Anton Burtsev January, 2017

CS3210: Virtual memory. Taesoo Kim w/ minor updates K. Harrigan

COL331/COL633 Minor2 Exam Operating Systems Sem II, Answer all 8 questions Max. Marks: 25

Introduction to Paging

CS 61 Section Notes 5

143A: Principles of Operating Systems. Lecture 7: System boot. Anton Burtsev October, 2017

Quiz I Solutions MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Department of Electrical Engineering and Computer Science

CS5460/6460: Operating Systems. Lecture 9: First process. Anton Burtsev January, 2014

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Quiz I

CS61 Scribe Notes Lecture 18 11/6/14 Fork, Advanced Virtual Memory

CS61 Scribe Notes Date: Topic: Fork, Advanced Virtual Memory. Scribes: Mitchel Cole Emily Lawton Jefferson Lee Wentao Xu

Processes. Johan Montelius KTH

A process. the stack

CS Week 10. Lab Assignment 3 pt 3 and Project 3. Teaching Assistant Henrique Potter

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Quiz I

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall 2008.

Project 3 - Virtual Memory Simulator. Simulate memory page allocation and page eviction algorithm

Computer Architecture and Engineering. CS152 Quiz #3. March 18th, Professor Krste Asanovic. Name:

CS Lab 1 xv6 Introduction Setup and exercise

CS164: Programming Assignment 5 Decaf Semantic Analysis and Code Generation

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Operating System Engineering: Fall 2003

Final Exam, Spring 2012 Date: May 14th, 2012

The Process Abstraction. CMPU 334 Operating Systems Jason Waterman

Quiz II Solutions MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Department of Electrical Engineering and Computer Science

Project 2: User Programs

CS510 Operating System Foundations. Jonathan Walpole

Project 1 System Calls

Virtual Memory I. CSE 351 Winter Instructor: Mark Wyse

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Quiz II Solutions. Mean 55.4 Median 58 Standard deviation 13.0

CS 537: Introduction to Operating Systems (Summer 2017) University of Wisconsin-Madison Department of Computer Sciences.

CS-537: Midterm Exam (Fall 2008) Hard Questions, Simple Answers

[537] Virtual Machines. Tyler Harter

CSC209F Midterm (L5101) Fall 1998 University of Toronto Department of Computer Science

Put your initials on the top of every page, in case the pages become separated.

Processes. CS 416: Operating Systems Design, Spring 2011 Department of Computer Science Rutgers University

Linux Memory Layout. Lecture 6B Machine-Level Programming V: Miscellaneous Topics. Linux Memory Allocation. Text & Stack Example. Topics.

CS 550 Operating Systems Spring Process II

Stanford University Computer Science Department CS 295 midterm. May 14, (45 points) (30 points) total

3. Process Management in xv6

Lab 4. Out: Friday, February 25th, 2005

CS3210: Virtual memory applications

ENCM 369 Winter 2019 Lab 6 for the Week of February 25

Midterm II December 4 th, 2006 CS162: Operating Systems and Systems Programming

Portland State University. CS201 Section 5. Midterm Exam. Fall 2018

Administrivia. - If you didn t get Second test of class mailing list, contact cs240c-staff. Clarification on double counting policy

A heap, a stack, a bottle and a rack. Johan Montelius HT2017

Changelog. Corrections made in this version not in first posting: 1 April 2017: slide 13: a few more %c s would be needed to skip format string part

x86 segmentation, page tables, and interrupts 3/17/08 Frans Kaashoek MIT

What You Need to Know for Project Three. Dave Eckhardt Steve Muckle

CS 3113 Introduction to Operating Systems Midterm October 11, 2018

CS 3113 Introduction to Operating Systems Midterm October 11, 2018

First Midterm Exam Solutions October 1, 2018 CS162 Operating Systems

CS 161 Computer Security

ENCM 369 Winter 2017 Lab 3 for the Week of January 30

Virtual Memory. CS 351: Systems Programming Michael Saelee

Computer Security Fall 2006 Joseph/Tygar Midterm 3

Winter 2012 MID-SESSION TEST Tuesday, March 6 6:30pm to 8:15pm. Please do not write your U of C ID number on this cover page.

Systems programming and Operating systems, 2005 Tentamen

Qualifying exam: operating systems, 1/6/2014

(In columns, of course.)

CSC369 Lecture 2. Larry Zhang, September 21, 2015

Midterm - Winter SE 350

CSC209F Midterm (L0101) Fall 1998 University of Toronto Department of Computer Science

Midterm 2. CMSC 430 Introduction to Compilers Fall 2018

CS 161 Computer Security

4. The Abstraction: The Process

Changelog. Changes made in this version not seen in first lecture:

CS 537: Introduction to Operating Systems Fall 2016: Midterm Exam #1. All cell phones must be turned off and put away.

User Programs. Computer Systems Laboratory Sungkyunkwan University

A2 Design Considerations. CS161, Spring

Virtual Memory. 11/8/16 (election day) Vote!

First Midterm Exam September 28, 2017 CS162 Operating Systems

Midterm - Winter SE 350

Virtual Memory: Concepts

CSC369 Lecture 2. Larry Zhang

Introduction. This project will focus primarily on processes.

Quiz I Solutions MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Department of Electrical Engineering and Computer Science

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Quiz II

There are 8 total numbered pages, 6 Questions. You have 60 minutes. Budget your time carefully!

Project 2--User Programs

CMSC 212 Midterm #2 (Fall 2005) ANSWERS AND GRADING KEY

ICS143A: Principles of Operating Systems. Lecture 14: System calls (part 2) Anton Burtsev November, 2017

Administrivia. Lab 1 due Friday 12pm. We give will give short extensions to groups that run into trouble. But us:

Transcription:

CS 238P Winter 2018 Midterm 02/20/2018 Time Limit: 3:30pm - 4:50am Name (Print): Don t forget to write your name on this exam. This is an open book, open notes exam. But no online or in-class chatting. Ask us if you something is confusing in the questions. Organize your work, in a reasonably neat and coherent way, in the space provided. Work scattered all over the page without a clear ordering will receive very little credit. Mysterious or unsupported answers will not receive full credit. A correct answer, unsupported by explanation will receive no credit; an incorrect answer supported by substantially correct explanations might still receive partial credit. If you need more space, use the back of the pages; clearly indicate when you have done this. Problem Points Score 1 10 2 10 3 5 4 10 5 5 6 5 Total: 45

CS 238P Midterm - Page 2 of 10 1. Basic page tables. Consider the following 32-bit x86 page table setup. %cr3 holds 0x00000000. The Page Directory Page at physical address 0x00000000: PDE 0: PPN=0x00001, PTE_P, PTE_U, PTE_W PDE 1: PPN=0x00002, PTE_P, PTE_U, PTE_W PDE 2: PPN=0x00001, PTE_P, PTE_U, PTE_W... all other PDEs are zero The Page Table Page at physical address 0x00001000 (which is PPN 0x00001): PTE 0: PPN=0x00003, PTE_P, PTE_U, PTE_W PTE 1: PPN=0x00004, PTE_P, PTE_U, PTE_W... all other PTEs are zero The Page Table Page at physical address 0x00002000: PTE 0: PPN=0x00005, PTE_P, PTE_U, PTE_W PTE 1: PPN=0x00004, PTE_P, PTE_U, PTE_W... all other PTEs are zero (a) (5 points) What are all virtual addresses mapped by this page table? (b) (5 points) What is the virtual address of the page table directory?

CS 238P Midterm - Page 3 of 10 2. Stack and calling conventions. Alice developed a program that has a function foo() that is called from two other functions bar() and baz(): int foo(int a) {... } int bar(int a, int b) {... foo(...);... } int baz(int a, int b, int c) {... foo(...);... } While debugging her program Alice observes the following state after pausing execution of the program inside foo() (assume that the compiler does not inline invocations of foo(), bar(), and baz(): The bottom of the stack: 0x8010b5b8:... 0x8010b5b4: 0x00010074 0x8010b5b0: 0x00000002 0x8010b5ac: 0x00000001 0x8010b5a8 0x80102e80 0x8010b5a4: 0x8010b5b8 0x8010b5a0: 0x80112780 0x8010b59c: 0x00000001 0x8010b598: 0x80102e32 0x8010b594: 0x8010b5a4 0x8010b590: 0x00000000 <-- ebp <-- esp (a) (5 points) Provide a short explanation for each line of the stack dump above (you can annotate the printout above).

CS 238P Midterm - Page 4 of 10 (b) (5 points) Can Alice make a conclusion if foo() is called from the context of bar() or baz() (explain your answer)?

CS 238P Midterm - Page 5 of 10 3. Process organization. (a) (5 points) xv6 processes have the following memory layout created as part of the exec() function. First, the kernel allocates pages for the kernel text and data (not that these pages are both executable and writable). Then xv6 allocates two pages: stack and guard. The guard page is made is placed between the stack and the rest of the program to make sure that if the stack overflows the operating system can catch an exception caused by the access to the guard page and terminate the program early. Alice thinks that the guard page mechanism is bulletproof, i.e., there is no way for a C program to overflow the stack and start overwriting the program text and data. Is she right, i.e., is it possible to write a C program that escapes the guard page mechanism and accidentally overwrites the text section of the program (provide an example).

CS 238P Midterm - Page 6 of 10 4. Physical and virtual memory allocation (a) (5 points) Xv6 uses 234MB of physical memory. But how does it keep track of available physical memory? Specifically, explain the following: the xv6 memory allocator (kalloc()) always returns a virtual address, but how does the allocator know which physical page to use for each virtual address it allocates? (b) (5 points) Xv6 defines the V2P() macro that allows the kernel to convert between virtual and physical addresses: #define V2P(a) (((uint) (a)) - KERNBASE) Does V2P() macro work for virtual addresses that belong to the user part of the address space (i.e., a virtual address inside the user data or stack)? Explain your answer.

CS 238P Midterm - Page 7 of 10 5. Exec and fork (a) (5 points) Heres a program that uses the UNIX system call API, as described in Chapter 0 of the xv6 book: #include "param.h" #include "types.h" #include "user.h" #include "syscall.h" int main() { char * message = "aaa\n"; int pid = fork(); if(pid!= 0){ } char *echoargv[] = { "echo", "Hello\n", 0 }; message = "bbb\n"; exec("echo", echoargv); write(1, message, 4); exit(); } Assume that fork() succeeds, that file descriptor 1 is connected to the terminal when the program starts, and echo program exists. What output this program produces (explain your answer)?

CS 238P Midterm - Page 8 of 10 6. Initial page tables Bob looks at the piece of code in entry.s where the initial page tables are set and thinks he doesn t need the entry that maps the 0-4MB of virtual page to 0-4MB of physical page. Accordingly he modifies the entrypgdir as below. attribute (( aligned (PGSIZE))) pde_t entrypgdir[npdentries] = { // Map VA s [KERNBASE, KERNBASE+4MB) to PA s [0, 4MB) [KERNBASE>>PDXSHIFT] = (0) PTE_P PTE_W PTE_PS, }; (a) (5 points) Explain whether Bob s change will work?

CS 238P Midterm - Page 9 of 10

CS 238P Midterm - Page 10 of 10