






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







First name, last name:.................................................................
In this part of the quiz, we would like to collect some information concerning your prior expe- rience with concurrent programming. What level of studies are you currently completing? Bachelor in Computer Science Master in Computer SciencePhD in Computer Science
Other:............................................................................. Which semester are you currently completing? (e.g. 4th).................................
Have you ever taken or are you currently taking a course other than Software Architecture thatcovers concurrent programming? YesNo No, but I studied it on my own (e.g. through online tutorials, books, ...) If yes, what course was/is it and when did you take it? (Please provide details below.) Parallel programming @ ETH Zurich by T. Gross in Spring............................. Concepts of concurrent computation @ ETH Zurich by B. Meyer in Spring.............. Other courses:
...................................................................................... ...................................................................................... How much of the self-study material on concurrency that you worked with today did you alreadyknow before?
none^ ^ 10%^ 20%^ 30%^ 40%^ 50%^ 60%^ 70%^ 80%^ 90%^ all
(1: a novice.. .5: an expert) Concerning your general programming experience, do you con- sider yourself...
Concerning your experience with concurrent programming, do you consider yourself...
Concerning your experience with the programming languagefel, do you consider yourself... Eif- (^1) (^2) (^3) (^4 5) Concerning your experience with the programming language Java, do you consider yourself... (^1) (^2) (^3) (^4 5) Concerning your experience with Java Threads, do you consider yourself...
Concerning your experience withself... SCOOP, do you consider your- (^1) (^2) (^3) (^4 5)
Where did you work through the self-study material? In the morning lecture In the exercise class At home
(1: totally disagree.. .5: totally agree) The self-study material was easy to follow. (^) (^1) (^2) (^3) (^4 5) The self-study material provided enoughunderstand the subject. examples to help me (^1) (^2) (^3) (^4 5) The self-study material provided enough exercises to help me un- derstand the subject.
I was able to complete the tutorial within 90 minutes. (^) (^1) (^2) (^3) (^4 5) The self-study material is a good alternative to the traditional lec-tures. (^1) (^2) (^3) (^4 5) I feel confident that I will be able to solve the tasks in this quiz. (^) (^1) (^2) (^3) (^4 5)
Any comments on the self-study material:................................................
...................................................................................... ...................................................................................... ...................................................................................... ......................................................................................
2 General concurrency concepts What is multiprocessing? Execution of multiple processes, within a single computer sharing a single processing unit. Execution of a single process on a single computer.Execution of a single process within multiple computers. Execution of multiple processes within a single computer sharing two or more processing units.
Which of the following state transitions is not possible in the status of a process? running ā ready readyblocked ā ā blocked ready running ā blocked
In the space below explain the terms data race and mutual exclusion.
...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... What is a deadlock? ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ......................................................................................
3 Comprehension Write down three possible (non-deadlock) outputs for the Java Threads program shown below:
...................................................................................... ...................................................................................... ......................................................................................
public class extends Thread Application { public static public static A aB b;; public static public static C cD d;; public void c = new C run(); a() { = new A(c); b System = new.out B(.cprint); d (^) (="A" new); D(); execute System.();out.print("L"); } public void a.start(); bexecute.start();() { d.foo(); try a (^) .{join(); b.join(); } catch if ((InterruptedException ea.done_a && b.done_b) { };) }^ System.out.print("M"); }
public class extends Thread A { C c boolean; done_a; public c = cc A;(C cc) { } public void try {m(); mrun();}() { catche (^) ) {};(InterruptedException } public void InterruptedException m() throws { synchronized while (!c.done (c) {) c.wait(); } synchronized (c) { }^ c.f();^ c.notifyAll(); }^ done_a^ =^ true; }
public class extends Thread B { C c boolean; done_b; public c = cc B;(C cc) { } public void try {n(); n run();}() { catche (^) ) {};(InterruptedException } public void InterruptedException n() throws { synchronized while (c.done (c)) { c.wait(); } synchronized (c) { }^ c.g();^ c.notifyAll(); done_b System. (^) out= true.print;("T"); }} public class public static void Root { main(String[] Application app^ args) { = new app.^ Applicationstart(); (); }}
public class boolean done C {; public void System.out f.() {print("F"); }^ done^ =^ false; public void System.out g.() {print("S"); }^ done^ =^ true; }
public class public void D { foo() { }^ System.out.print("P"); }
Line number Explanation
Line.............................................................................
..................................................................... ..................................................................... Line............................................................................. ..................................................................... ..................................................................... Line............................................................................. ..................................................................... ..................................................................... Line............................................................................. ..................................................................... ..................................................................... Line............................................................................. ..................................................................... ..................................................................... Line............................................................................. ..................................................................... ..................................................................... Line............................................................................. ..................................................................... ..................................................................... Line............................................................................. ..................................................................... .....................................................................
5 Program Construction Consider a class Data with two integer fields x and y, both of which are initialized to 0. Two classesbehavior, which is repeated continuously: if both values C0 and C1 share an object data of type Data. (^) dataClass.x C0and implements the following data.y are set to 1, it sets both values to 0; otherwise it waits until both values are 1. Conversely, classfollowing behavior, which is also repeated continuously: if both values data. (^) xC1 and implements the data.y are set to 0, it sets both values to 1; otherwise it waits until both values are 0. The following condition must always hold when data is accessed: (data.x = 0 ⧠data.y = 0 ) ⨠(data.x = 1 ⧠data.y = 1 )
Besides the mentioned classes^ Write a concurrent program using Java Threads that implements the described functionality. Data, C0, and C1, your program needs to have a root class which ensures that the behaviors of C0 and C1 are executed in different threads.
...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ......................................................................................
Feedback on the quiz How much time did you spend on this quiz? 20ā 30ā 40ā 50ā 60ā 70ā 80ā 90ā 100ā 110ā 120ā The difficulty level of the quiz was.. .(1: too easy, 2: easy, 3: just right, 4: difficult, 5: too difficult) (^1) (^2) (^3) (^4 5) I feel confident that I solved the tasks of this quiz correctly.(1: totally disagree... 5: totally agree) (^1) (^2) (^3) (^4 5)
Did you leave any questions of the quiz empty and if so, why?.............................
...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ......................................................................................
Any comments on the quiz:.............................................................
...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ...................................................................................... ......................................................................................