CS 351 Sample Final Exam, Spring 2015

Similar documents
Lecture 17. Log into Linux. Copy two subdirectories in /home/hwang/cs375/lecture17/ $ cp r /home/hwang/cs375/lecture17/*.

Contents. IPC (Inter-Process Communication) Representation of open files in kernel I/O redirection Anonymous Pipe Named Pipe (FIFO)

CS 550 Operating Systems Spring Inter Process Communication

Concurrent Programming. Concurrent Programming with Processes and Threads

Pipes and FIFOs. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Contents. PA1 review and introduction to PA2. IPC (Inter-Process Communication) Exercise. I/O redirection Pipes FIFOs

Inter-Process Communication

CSE 410: Systems Programming

Processes COMPSCI 386

Main Memory: Address Translation

registers data 1 registers MEMORY ADDRESS on-chip cache off-chip cache main memory: real address space part of virtual addr. sp.

Design Overview of the FreeBSD Kernel CIS 657

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent?

CMSC 313 Spring 2010 Exam 3 May 17, 2010

CSE 120 Principles of Operating Systems

15-213/18-243, Spring 2011 Exam 2

Virtual Memory. Virtual Memory

Creating a Shell or Command Interperter Program CSCI411 Lab

Pipelined processors and Hazards

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 27, SPRING 2013

CSE351 Spring 2018, Final Exam June 6, 2018

Processes. Process Concept

20-EECE-4029 Operating Systems Spring, 2013 John Franco

CMSC 313 Lecture 14 Reminder: Midterm Exam next Tues (10/26) Project 4 Questions Virtual Memory on Linux/Pentium platform

COSC Operating Systems Design, Fall Lecture Note: Unnamed Pipe and Shared Memory. Unnamed Pipes

Inter-process Communication. Using Pipes

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 27, FALL 2012

CS 153 Design of Operating Systems Winter 2016

CSE 120 Principles of Operating Systems Spring 2017

CSE 153 Design of Operating Systems

CS F-MID Midterm October 25, 2001

CS Programming In C

Outline. OS Interface to Devices. System Input/Output. CSCI 4061 Introduction to Operating Systems. System I/O and Files. Instructor: Abhishek Chandra

Address spaces and memory management

ENGR 3950U / CSCI 3020U Midterm Exam SOLUTIONS, Fall 2012 SOLUTIONS

CSE351 Winter 2016, Final Examination March 16, 2016

Process Management! Goals of this Lecture!

OS COMPONENTS OVERVIEW OF UNIX FILE I/O. CS124 Operating Systems Fall , Lecture 2

CIS Operating Systems Memory Management Address Translation for Paging. Professor Qiang Zeng Spring 2018

CS Operating system Summer Midterm I -- July 11, 2017 You have 115 min (10:00am-11:55pm). Good Luck!

CS 550 Operating Systems Spring File System

CMSC 313 Lecture 13 Project 4 Questions Reminder: Midterm Exam next Thursday 10/16 Virtual Memory

CS 318 Principles of Operating Systems

Lecture 2: February 6

What Is Operating System? Operating Systems, System Calls, and Buffered I/O. Academic Computers in 1983 and Operating System

Basic Memory Management

CIS Operating Systems Memory Management Page Replacement. Professor Qiang Zeng Spring 2018

Page 1. Review: Address Segmentation " Review: Address Segmentation " Review: Address Segmentation "

CS252 S05. Main memory management. Memory hardware. The scale of things. Memory hardware (cont.) Bottleneck

Interprocess Communication E. Im

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes

Recall: Address Space Map. 13: Memory Management. Let s be reasonable. Processes Address Space. Send it to disk. Freeing up System Memory

CS 261 Fall Mike Lam, Professor. Virtual Memory

Final exam. Scores. Fall term 2012 KAIST EE209 Programming Structures for EE. Thursday Dec 20, Student's name: Student ID:

CSC209 Review. Yeah! We made it!

CS Operating system Fall Midterm I -- Oct 5, 2017 You have 75 min. Good Luck!

Key Point. What are Cache lines

RCU. ò Walk through two system calls in some detail. ò Open and read. ò Too much code to cover all FS system calls. ò 3 Cases for a dentry:

VFS, Continued. Don Porter CSE 506

1. Creates the illusion of an address space much larger than the physical memory

IC221: Systems Programming 12-Week Written Exam [SOLUTIONS]

CS 43: Computer Networks. 07: Concurrency and Non-blocking I/O Sep 17, 2018

Pipes. Pipes Implement a FIFO. Pipes (cont d) SWE 545. Pipes. A FIFO (First In, First Out) buffer is like a. Pipes are uni-directional

CS 322 Operating Systems Practice Midterm Questions

Operating Systems. 09. Memory Management Part 1. Paul Krzyzanowski. Rutgers University. Spring 2015

CSE 141 Computer Architecture Spring Lectures 17 Virtual Memory. Announcements Office Hour

CSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management

Cache Memory and Performance

CIS Operating Systems Memory Management Cache Replacement & Review. Professor Qiang Zeng Fall 2017

CS 3214 Final Exam. To be considerate to your fellow students, if you leave early, do so with the least amount of noise.

Memory management units

Final Exam Solutions May 11, 2012 CS162 Operating Systems

Recitation 7 Caches and Blocking. 9 October 2017

14:332:331. Week 13 Basics of Cache

ECE 485/585 Microprocessor System Design

Physical memory vs. Logical memory Process address space Addresses assignment to processes Operating system tasks Hardware support CONCEPTS 3.

Main Memory. CISC3595, Spring 2015 X. Zhang Fordham University

My malloc: mylloc and mhysa. Johan Montelius HT2016

Dynamic Memory: Alignment and Fragmentation

10. I/O System Library

CS527 Software Security

Layers in a UNIX System. Create a new process. Processes in UNIX. fildescriptors streams pipe(2) labinstructions

Lecture 23: System-Level I/O

Processes often need to communicate. CSCB09: Software Tools and Systems Programming. Solution: Pipes. Recall: I/O mechanisms in C

Caching and Demand-Paged Virtual Memory

Recap: Memory Management

Q 1. (10 Points) Assume that a process executes the following pseudo codes:

( B ) 4. Which is not able to solve the race condition? (A) Test and Set Lock (B) Shared memory (C) Semaphore (D) Monitor

Process Management! Goals of this Lecture!

File Descriptors and Piping

Exercise 1.1 Hello world

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1

Virtual Memory. CS 351: Systems Programming Michael Saelee

Operating Systems CS 217. Provides each process with a virtual machine. Promises each program the illusion of having whole machine to itself

198:231 Intro to Computer Organization. 198:231 Introduction to Computer Organization Lecture 14

( D ) 4. Which is not able to solve the race condition? (A) Test and Set Lock (B) Semaphore (C) Monitor (D) Shared memory

System-Level I/O. Topics Unix I/O Robust reading and writing Reading file metadata Sharing files I/O redirection Standard I/O

Basic OS Progamming Abstrac7ons

File I/O and File Systems

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

Transcription:

CS 351 Sample Final Exam, Spring 2015 Before starting the exam, make sure that you write and bubble in your student ID number (omitting the leading 'A') on the answer sheet in the field labeled "Student Number". For each question, choose the single best answer and fill in the corresponding bubble on the answer sheet. Feel free to scribble on this question paper, but be sure to turn it in at the end of the exam! 1. Which system call may result in the deallocation of an open file description object? (a) open (b) read (c) exit (d) dup 2. Which piece of information is not maintained within the v-node structure? (a) file permissions (b) data location (e.g., on disk) (c) file size (d) current file position 3. What is a limitation of unnamed pipes? (a) a hard limit of 2 processes that can read/write them at any time (b) their lack of synchronization when it comes to IPC (c) the loss of data stored in them after the writing process terminates (d) not being able to use one for IPC with a process that doesn't already have a reading/ writing end 4. What is a primary incentive for implementing user-level buffered I/O (on top of the I/O system calls)? (a) reducing the number of I/O system calls (b) eliminating the possibility of short counts (c) supporting the standard input/output/error abstraction (d) allowing processes to share files without going through the kernel

5. What is a strong argument against using regular files for dynamic IPC? (a) separate processes cannot simultaneously read/write regular files (b) regular files are more prone to short counts (than purpose-built IPC mechanisms) (c) coordinating separate (e.g., read/write) positions in regular files is tricky (d) data stored in regular files does not persist after a process exits

6. For this and the next question, consider the following function, read_write, which makes use of the buffered stdio function fread: void read_write(file *stream, int n) { char buf[100]; /* read n bytes from stream into buf */ int nread = fread(buf, 1, n, stream); /* print bytes read to stdout */ write(1, buf, nread); Note that fread takes three arguments in addition to the destination buffer: - the size of each item to read (1 byte, in the given invocation) - the number of items to read (n) - the stream from which to read the items Assume that stream buffers are 4KB large. Now consider the following program, which contains two separate calls to read_write: main() { FILE *infile = fopen("foo.txt", "r"); if (fork() == 0) { read_write(infile, 6); else { wait(null); read_write(infile, 6); Given that the file "foo.txt" contains the single line of text: (a) Lorem Lorem ipsum dolor sit amet What would be the output of the above program (from parent and child processes combined)? (b) Lorem Lorem (c) Lorem ipsum (d) No output is produced

7. Based on the same read_write function and "foo.txt" file from the previous problem, we make a minor modification to the program as show below, "priming" the stream with yet another call to read_write: main() { FILE *infile = fopen("foo.txt", "r"); read_write(infile, 6); /* initial read/write */ if (fork() == 0) { read_write(infile, 6); else { wait(null); read_write(infile, 6); What is the output of this program? (a) Lorem ipsum (b) Lorem ipsum dolor (c) Lorem ipsum ipsum (d) Lorem ipsum Lorem

11. For this and the next three questions, consider the following function which takes pointers 8. The following program makes use of an unnamed pipe to facilitate communication between two processes. (a) 12345- (b) 34512- int main() { int i, n, pfds[2]; char c, buf[80]; pipe(pfds); if (fork() == 0) { for (c='1'; c<='5'; c++) { write(pfds[1], &c, 1); else { close(pfds[1]); while ((n = read(pfds[0], buf, sizeof(buf))) > 0) { write(1, buf, n); write(1, "-", 1); Which of the following is not a possible output of the program? (c) 1-2-3-4-5- (d) All the above are possible 9. Which of the following caching policies requires the addition of a dirty bit to each cache line? (a) write-through (b) write-around (c) write-allocate (d) write-back 10. Which of the following combinations of write caching policies allow for write absorption at the cache level?

(b) 25% (¼) 10. Which of the following combinations of write caching policies allow for write absorption at the cache level? (a) write-through + write-around (b) write-through + write-back (c) write-back + write-allocate (d) write-back + write-around 11. For this and the next three questions, consider the following function which takes pointers to two non-overlapping arrays (arr1, arr2) of random, word-sized elements, and the number (n) of elements in each to be processed: int foo (int *arr1, int *arr2, int n) { int i, accum; for (i=0; i<n; i++) /* loop #1 */ accum += arr1[i]; for (i=0; i<n; i++) /* loop #2 */ accum += arr2[(2*i) % n]; for (i=0; i<n; i++) /* loop #3 */ accum += arr1[i] * arr2[i] return accum; Make the following assumptions: - the cache is 2-way set associative with 2-word blocks - all local variables (excluding arrays) are mapped to registers by the compiler - data in arr1 and arr2 are uncached before foo is called What is the approximate best case hit rate for loop #1? (b) 25% (¼) (c) 50% (½) (d) 100% 12. What is the approximate best case hit rate for loop #2?

(d) 100% 12. What is the approximate best case hit rate for loop #2? (b) 25% (¼) (c) 50% (½) (d) 100% 13. What is the approximate best case hit rate for loop #3 (given that it was preceded by loops #1 and #2)? (b) 25% (¼) (c) 50% (½) (d) 100% 14. What is the approximate worst case hit rate for loop #3 (given that it was preceded by loops #1 and #2)? (b) 25% (¼) (c) 50% (½) (d) 100% 15. What is a primary justification for enforcing alignment of data in memory? (a) improving cache utilization (b) reducing memory fragmentation (c) improving memory (DRAM) utilization (d) simplifying compilation 16. What is a primary justification for making use of the lower bits of an address to compute the cache index? (a) improving cache utilization (b) to better leverage good temporal locality (c) to better leverage good spatial locality (d) to reduce the likelihood of cache collisions 17. A relatively large miss penalty at a given level of caching is good justification for which of the following?

(d) to reduce the likelihood of cache collisions 17. A relatively large miss penalty at a given level of caching is good justification for which of the following? (a) implementing the write-around policy (b) increasing associativity to improve hit rate (c) using a simple cache design to optimize the hit time (d) implementing the write-through policy 18. Given a fixed cache (data) size, what strategy best deals with the problem of cache thrashing? (a) decreasing the block size (b) increasing the block size (c) decreasing associativity (d) increasing associativity 19. (See slide 86 of Memory Hierarchy & Caching slides for examples of direct-mapped cache lookup exercises) 20. (See slide 109 of Memory Hierarchy & Caching slides for examples of associative cache lookup exercises)