MCS-378 Intraterm Exam 1 Serial #:

Similar documents
MCS-378 Intraterm Exam 1 Serial #:

MCS-377 Intra-term Exam 1 Serial #:

CSE 131S Introduction to Computer Science Summer SON Exam I

CMSC330 Spring 2014 Midterm #2. Score 1 OCaml types & type

CS140 Operating Systems and Systems Programming Midterm Exam

Note: in this document we use process and thread interchangeably.

Prelim 1. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants

COS 126 Midterm 1 Written Exam Fall 2014!

COS 126 General Computer Science Spring Written Exam 1

Java Threads. Written by John Bell for CS 342, Spring 2018

ECE 462 Exam 3. 11:30AM-12:20PM, November 17, 2010

Java Threads. COMP 585 Noteset #2 1

MCS-274 Final Exam Serial #:

CS140 Operating Systems and Systems Programming Midterm Exam

Problem Score Max Score 1 Syntax directed translation & type

Info 408 Distributed Applications Programming Exercise sheet nb. 4

COS 126 Midterm 1 Written Exam Fall 2011

Programming Language Concepts: Lecture 11

CS 101 Fall 2006 Midterm 3 Name: ID:

7. MULTITHREDED PROGRAMMING

COMP 524 Spring 2018 Midterm Thursday, March 1

CS 3114 Data Structures and Algorithms READ THIS NOW!

Object Oriented Programming. Week 10 Part 1 Threads

CS 140 Midterm Examination Winter Quarter, 2012

CS 3114 Data Structures and Algorithms Test 1 READ THIS NOW!

CS140 Operating Systems and Systems Programming Final Exam

CSE 131S Introduction to Computer Science Summer SON Exam III

Threads Chate Patanothai

MIDTERM EXAM March 28, 2018

This exam is open book. Each question is worth 3 points.

CSE 131 Introduction to Computer Science Fall Exam I

CS140 Operating Systems and Systems Programming Final Exam

CMSC 433 Section 0101 Fall 2012 Midterm Exam #1

Prelim 1, Solution. CS 2110, 13 March 2018, 7:30 PM Total Question Name Short answer

CSE 131 Introduction to Computer Science Fall Exam III

Java 2 Programmer Exam Cram 2

Concurrent and Real-Time Programming in Java

CS18000: Programming I

Faculty of Computers & Information Computer Science Department

Multi-threaded programming in Java

Part 1 (80 points) Multiple Choice Questions (20 questions * 4 points per question = 80 points)

CSE 131 Introduction to Computer Science Fall Exam I

Animation Part 2: MoveableShape interface & Multithreading

COS 318: Midterm Exam (October 23, 2012) (80 Minutes)

EECS489 Computer Networks, Take-home Makeup Midterm (Winter 2007) due in class Wednesday 3/28

Real-Time and Concurrent Programming Lecture 4 (F4): Monitors: synchronized, wait and notify

Winter 2017 Feb 13 th, 2017 CS106A Midterm. Last Name: First Name: Sunet ID (eg jdoe): Section Leader / Grader:

CS 101 Exam 1 Spring 200 Id Name

Do not start the test until instructed to do so!

Lab 3 Process Scheduling Due date: 29-Nov-2018

ECE Fall 2015, First Exam

B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA

EINDHOVEN UNIVERSITY OF TECHNOLOGY

Threads and Parallelism in Java

CSC 716 Advanced Operating System Fall 2007 Exam 1. Answer all the questions. The maximum credit for each question is as shown.

CMSC 433 Spring 2013 Exam 1

CSE 131 Introduction to Computer Science Fall Exam II

CSCE 206: Structured Programming in C++

CS 2505 Computer Organization I Test 1. Do not start the test until instructed to do so! printed

University of Illinois at Urbana-Champaign Department of Computer Science. First Examination

Exam Concurrent and Real-Time Programming

MCS-284 Final Exam Serial #:

CS 134 Midterm Solutions Spring 2013

Final Exam. COMP Summer I June 26, points

Written by John Bell for CS 342, Spring 2018

CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2015

Need for synchronization: If threads comprise parts of our software systems, then they must communicate.

re-exam Concurrent Programming tda383/dit390 Date: Time: 14:00 18:00 Place: Maskinhuset (M)

public class Shared0 { private static int x = 0, y = 0;

ECE264 Fall 2013 Exam 1, September 24, 2013

CS140 Operating Systems and Systems Programming Midterm Exam

ECE462Exam3. 08:10-09:20AM, November 20, 2009

CS 2506 Computer Organization II Test 1. Do not start the test until instructed to do so! printed

COS 126 Midterm 1 Written Exam, Fall 2009

CS 134 Midterm Spring 2013

Models of concurrency & synchronization algorithms

COS 226 Algorithms and Data Structures Fall Midterm

Concurrent Programming using Threads

CSE 131 Introduction to Computer Science Fall 2016 Exam I. Print clearly the following information:

CS 351 Design of Large Programs Threads and Concurrency

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring Instructions:

Monitors & Condition Synchronization

Contribution:javaMultithreading Multithreading Prof. Dr. Ralf Lämmel Universität Koblenz-Landau Software Languages Team

CSC 210, Exam Two Section February 1999

Advanced Concepts of Programming

Exam Number/Code : 1Z Exam Name: Name: Java Standard Edition 6. Demo. Version : Programmer Certified Professional Exam.

Java Barrier Synchronizers: CyclicBarrier (Part 1)

SysGauge SYSTEM MONITOR. User Manual. Version 4.7. Apr Flexense Ltd.

Chair of Software Engineering. Java and C# in depth. Carlo A. Furia, Marco Piccioni, Bertrand Meyer. Java: concurrency

1 Inheritance (8 minutes, 9 points)

Midterm Exam. CS169 Fall November 17, 2009 LOGIN: NAME: SID: Problem Max Points Points TOTAL 100

Final exam. CS 2110, December 15, 2016, 9:00AM

CS140 Operating Systems and Systems Programming

ECE264 Fall 2013 Exam 3, November 20, 2013

Midterm Exam Amy Murphy 19 March 2003

Producing Production Quality Software. Lecture 12: Concurrent and Distributed Programming Prof. Arthur P. Goldberg Fall, 2004

sample exam Concurrent Programming tda383/dit390 Sample exam March 2016 Time:?? Place: Johanneberg

Concurrency in Java Prof. Stephen A. Edwards

Contents. 6-1 Copyright (c) N. Afshartous

CmpSci 187: Programming with Data Structures Spring 2015

Transcription:

MCS-378 Intraterm Exam 1 Serial #: This exam is closed-book and mostly closed-notes. You may, however, use a single 8 1/2 by 11 sheet of paper with hand-written notes for reference. (Both sides of the sheet are OK.) Please write your name only on this page. Do not turn the page until instructed, in order that everyone may have the same time. Then, be sure to look at all problems before deciding which one to do first. Some problems are easier than others, so plan your time accordingly. You have 50 minutes to work. Write the answer to each problem on the page on which that problem appears. You may also request additional paper, which should be labeled with your test number and the problem number. Printed name: On my honor, I pledge that I have not given, received, nor tolerated others use of unauthorized aid in completing any work for this course. Signature for above honor pledge: Problem Page Possible Score 1 2 20 2 3 20 3 4 20 4 5 20 5 6 20 Total 100

MCS-378-2- Serial #: 1. [ 20 Points ] Suppose thread A goes through a loop 100 times, each time performing one disk I/O operation, taking 9 ms, and then some computation, taking 3 ms. While each 9 ms disk operation is in progress, thread A cannot make any use of the processor. Thread B runs for 1 second, purely in the processor, with no I/O. One millisecond of processor time is spent each time the processor switches threads; other than this switching cost, there is no problem with the processor working on thread B during one of thread A s I/O operations. (The processor and disk drive do not contend for memory access bandwidth, for example.) Give your answers to the following questions in milliseconds. (a) Suppose the processor and disk work purely on thread A until its completion, then the processor switches to thread B and runs all of that thread. What will the total elapsed time be? (b) Suppose the processor starts out working on thread A, but every time thread A performs a disk operation, the processor switches to B during the operation, then back to A upon the disk operation s completion. What will the total elapsed time be?

MCS-378-3- Serial #: 2. [ 20 Points ] Suppose thread T1 is triggered by an event at time 0 and needs to run for 4 seconds before it can respond. Suppose thread T2 is triggered by an event occuring later than T1 s trigger, and that T2 needs to run 2 seconds before it can respond. Draw a Gantt chart for each of the following four cases, and for each indicate the response time of T1, the response time of T2, and the average response time: (a) T2 is triggered by an event that is 1 second later than T1 s trigger; T1 is allowed to run to completion before T2 is run. (b) T2 is triggered by an event that is 1 second later than T1 s trigger; T1 is preempted when T2 is triggered; only after T2 has completed does T1 resume. (c) T2 is triggered by an event that is 3 seconds later than T1 s trigger; T1 is allowed to run to completion before T2 is run. (d) T2 is triggered by an event that is 3 seconds later than T1 s trigger; T1 is preempted when T2 is triggered; only after T2 has completed does T1 resume. Generalizing from cases (a)-(d), we can imagine situations where T2 would be triggered at some other time during T1 s execution (not just at 1 second or 3 seconds). We could even further generalize and consider execution times for T1 and T2 other than 4 and 2 seconds. State a general rule for when the average response time is minimized by allowing T1 to continue running and when it is minimized by preempting T1 and running T2.

MCS-378-4- Serial #: 3. [ 20 Points ] (a) Complete the following Java class, Resource, which is to be used in a multi-threaded program to represent the available quantity of some resource. Each newly created resource has a quantity of 0. The change operation can be used to change the quantity; if the argument (delta) is positive, the quantity goes up by the specified amount. If the argument is negative, it still specifies how much the quantity should change by, but this now naturally means that the quantity goes down. You are to complete the code in such a way that any thread performing a change operation is temporarily suspended if necessary to ensure that the quantity never goes negative. public class Resource { private int quantity = 0; public synchronized void change(int delta) throws InterruptedException { } } quantity = quantity + delta; notifyall(); (b) What modification could be made in the code I provided that might improve its efficiency without hurting its correctness?

MCS-378-5- Serial #: 4. [ 20 Points ] Write down five different two-phase histories that would be possible for a transaction, T 1, that first reads x, then writes y, then writes z. In at least two of your five histories, avoid grouping all the unlock operations together at the end of the history.

MCS-378-6- Serial #: 5. [ 20 Points ] Give an example of a transaction where it matters that undo log entries are processed in reverse chronological order and explain why it matters.