GRIFFITH COLLEGE DUBLIN
QUALITY AND QUALIFICATIONS IRELAND
EXAMINATION
POSTGRADUATE DIPLOMA IN SCIENCE IN BIG DATA MANAGEMENT
AND ANALYTICS
PARALLEL AND DISTRIBUTED PROGRAMMING
Module Code: PGDBD-PDP
MASTER OF SCIENCE IN BIG DATA MANAGEMENT AND ANALYTICS
PARALLEL AND DISTRIBUTED PROGRAMMING
Module code: MSCBD-PDP
Lecturer(s): Osama Abushama
External Examiner(s): Dr William Clifford
Date: 22nd January 2024 Time: 2.15-5.15
THIS PAPER CONSISTS OF FIVE QUESTIONS
FOUR QUESTIONS TO BE ATTEMPTED
ALL QUESTIONS CARRY EQUAL MARKS
Page 1 of 3
QUESTION 1
(a) What do we understand by the term race condition? How can it be prevented?
(10 marks)
(b) What do we understand by fair locks?
(5 marks)
(c) What is the difference between notify() and notifyAll()?
(5 marks)
(d) How it is determined which thread wakes up by calling notify()?
(5 marks)
Total (25 marks)
QUESTION 2
The programming language Java provides for monitors by means of locks and condition variables.
Locks can be declared and initialized by means of
[Link] lock = new [Link]();
Condition variables are obtained from a given lock by means of
[Link] c1 = [Link]();
(a) Explain how locks are used to implement mutual exclusion synchronization.
(5 marks)
(b) Explain what happens when a program executes [Link]()
(5 marks)
(c) Explain what happens when a program executes [Link]().
(5 marks)
(d) Explain what is meant with signal and continue in this context.
(5 marks)
(e) Explain what the difference is when using a binary semaphore instead of a lock.
(5 marks)
Total (25 marks)
Page 2 of 3
QUESTION 3
(a) A car park has space for 100 cars. There are many turnstiles (mechanical gates) letting cars
in and out. As cars come in a shared counter is incremented. As cars leave the park, the
shared counter is decremented. Implement a class to control the parking place using
ReentrantLock. See to it that if there are 100 cars in the park, processes trying to increment
the counter get delayed until some car leaves the park (this will cause the turnstile to be kept
closed without letting the car in, but you do not have to worry about this, you are not
implementing the turnstile processes!)
(20 marks)
(b) Explain what communication takes place and how the processes are synchronized during
this communication.
(5 marks)
Total (25 marks)
QUESTION 4
(a) Write a parallel OpenMP C program to perform matrix-vector multiplication.
(10 marks)
(b) Write a parallel MPI C program to perform matrix-vector multiplication, c = A × b, based on
row wise block-striped decomposition of A and c and replicated b.
(15 marks)
Total (25 marks)
QUESTION 5
(a) Write a recursive Java class to count the frequency of odd numbers in a large array using
ForJoinPool.
(15 marks)
(b) Explain why the class Counter, listed below, is not thread safe and re-write it so that it is.
class Counter{
private static int next = 0;
synchronized static int getNext(){
next++;
return next;
}
synchronized void reset(){
next = 0;
}
}
(10 marks)
Total (25 marks)
Page 3 of 3