CS Elective Flashcards
- START OF FA1-A1 -
The tightly coupled set of threads’ execution working on a single task is called Parallel Processing. (T/F)
FALSE (?)
Parallelism naturally leads to complexity. (T/F)
FALSE** (CORRECT)
Parallelism naturally leads to concurrency. (T/F)
TRUE
A key advantage of distributed memory architectures is that they are more scalable than shared memory systems. (T/F)
TRUE
Multiple-applications independently running, are typically called Multithreading. (T/F)
FALSE (CORRECT)
Threads being blocked altogether and being executed in the sets of 32 threads are called Unit Blocks. (T/F)
FALSE (CORRECT)
A Symmetric Multi-Processing (SMP) system has two or more _____ processors connected to a single _____ main memory.
IDENTICAL;SHARED (CORRECT)
Threads being blocked altogether and being executed in the sets of 128 threads are called Unit Blocks. (T/F)
FALSE
In most modern multi-core CPUs, cache coherency is usually handled by the _____.
processor hardware (CORRECT)
If private data is used by a single-processor, then shared data is used by a multi-processor. (T/F)
TRUE*** (CORRECT)
Distributed memory can be easily scaled. (T/F)
TRUE
UMA stands for Universal Memory Access. (T/F)
FALSE (CORRECT)
Modern multi-core PCs fall into the MIMD classification of Flynn’s Taxonomy. (T/F)
TRUE (CORRECT)
Nonuniform Memory Access is often made by logically connecting multiple SMP systems together (T/F)
FALSE (CORRECT)
In a concurrent memory architecture, each processor operates independently, and cannot make changes to its local memory. (T/F)
FALSE (CORRECT)
Computer memory usually operates at a much faster speed than processors do. (T/F)
FALSE** (CORRECT)
Distributed memory scales better than Shared memory. (T/F)
TRUE (CORRECT)
Parallel computing can increase the number of tasks a program executes in a set time. (T/F)
TRUE (CORRECT)
It is necessary in shared memory that the data exists on the same physical device, hence it could not be spread across a cluster of systems. (T/F)
FALSE (CORRECT)
- START OF F3 -
In Java program, data race only occurs when each of the threads are incrementing a shared variable a large number of time because the JVM’s automatic data race prevention system can only protect against a small number of operations. (T/F)
False (CORRECT)
A maximum of 2 threads can possess a Lock at the same time. (T/F)
FALSE (CORRECT)
Which of these scenarios does NOT have the potential for a data race?
Group of answer choices
Two threads are both reading and writing the same shared variable.
One thread is reading a shared variable while another thread writes to it.
Two threads are both reading the same shared variable.
Two threads are both writing to the same shared variable.
Two threads are both reading the same shared variable. (CORRECT)
Read-write locks can improve a program’s performance compared to using a standard mutex. (T/F)
TRUE (CORRECT)
Two threads that are both reading and writing the same shared variable has no potential for a data race. (T/F)
FALSE (CORRECT)
No thread can possess the ReadLock while another thread has a lock on the WriteLock. (T/F)
TRUE** (CORRECT)
The reader-writer lock is useful especially when there are lots of threads that only need to be read. (T/F)
TRUE
Data races can be hard to identify because the data race may not always occur during execution to cause a problem. (T/F)
TRUE (CORRECT)
A maximum of 1 thread can possess the WriteLock of a ReentrantReadWriteLock at a time. (T/F)
TRUE (CORRECT)
Locker Mutex protects critical section of the code to defend against data races, which can occur when multiple threads are concurrently accessing the same location in memory and at least one of those threads is writing to that location. (T/F)
TRUE (CORRECT)
A possible strategy to resolve a livelock between multiple threads is thru randomly terminating one of the threads involved in the livelock. (T/F)
FALSE (CORRECT)
Data race occurs when a thread is unable to gain access to a necessary resource, and is therefore unable to make progress. (T/F)
FALSE (CORRECT)
Why is the tryLock() method useful?
Group of answer choices
If multiple threads try to acquire a lock simultaneously, the tryLock() method will randomly pick one to succeed.
It enables a thread to execute alternate operations if the lock it needs to acquire is already taken.
It enforces fairness among multiple threads competing for ownership of the same lock.
It includes built-in protection against common locking errors.
It enables a thread to execute alternate operations if the lock it needs to acquire is already taken. (CORRECT)
When a thread calls Java’s tryLock() method on a Lock that is NOT currently locked by another thread the method will block until the Lock is available and then return false. (T/F)
FALSE (CORRECT)
Unlike during a deadlock, the threads in a livelock scenario are actively executing without making useful progress. (T/F)
TRUE (CORRECT)
The lock() method can be called recursively on a ReentrantLock object, but not on a regular Lock object. (T/F)
FALSE** (CORRECT)
A thread must unlock a ReentrantLock twice before another thread can acquire it. (T/F)
FALSE (CORRECT)
When the threads in the program are not making progress, you can determine if it is due to a deadlock or a livelock by using the Resource Monitor to investigate the program’s CPU usage to see if it is actively executing. (T/F)
TRUE (CORRECT)
Which statement describes the relationship between Lock and ReentrantLock in Java?
Group of answer choices
The lock() method can be called recursively on a ReentrantLock object, but not on a regular Lock object.
Lock and ReentrantLock are two names for the same class.
ReentrantLock is a class that implements the Lock interface.
A ReentrantLock instantiates a new internal Lock object every time its lock() method is called.
ReentrantLock is a class that implements the Lock interface. (CORRECT)
The tryLock() method is useful because if multiple threads try to acquire a lock simultaneously, the tryLock() method will randomly pick one to succeed. (T/F)
- END OF FA3-A1, 18/20 -
25* CORRECTED
35* CORRECTED
FALSE (CORRECT)
- START OF FA3-A2 -
Protecting a critical section of code with mutual exclusion means that whenever a thread enters the critical section, it pauses all other threads in the program. (T/F)
FALSE (CORRECT)
One thread that is reading a shared variable while another thread writes to it has no potential for a data race. (T/F)
FALSE (CORRECT)
Two threads that are both reading the same shared variable has no potential for a data race. (T/F)
TRUE (CORRECT)
The best use case for using a ReadWriteLock is when lots of threads need to modify the value of a shared variable. (T/F)
FALSE (CORRECT)
A maximum of 2 threads can possess the ReadLock while another thread has a lock on the WriteLock? (T/F)
FALSE
Data races can be hard to identify because the problems that data races cause have an insignificant impact on the program’s performance. (T/F)
FALSE (CORRECT)
When the threads in the program are not making progress, you can determine if it is due to a deadlock or a livelock by using the Resource Monitor to investigate the program’s memory usage to see if it continues to grow. (T/F)
FALSE (CORRECT)
When a thread calls Java’s tryLock() method on a Lock that is NOT currently locked by another thread the method will block until the Lock is available and then return true. (T/F)
FALSE (CORRECT)
A ReentrantLock can be locked multiple times by different threads. (T/F)
FALSE (CORRECT)
A ReentrantLock instantiates a new internal Lock object every time its lock() method is called. (T/F)
FALSE (CORRECT)
Unlike during a deadlock, the threads in a livelock scenario are still making progress towards their goal. (T/F)
- END OF FA3-A2 = 20/20 -
FALSE (CORRECT)
- START OF FA3-A3 -
Two threads that are both reading and writing the same shared variable has the potential for a data race. (T/F)
TRUE (CORRECT)
The best use case for using a ReadWriteLock is when lots of threads need to modify the value of a shared variable, but only a few thread need to read its value. (T/F)
FALSE (CORRECT)
Two threads that are both writing to the same shared variable has no potential for a data race. (T/F)
FALSE (CORRECT)
The best use case for using a ReadWriteLock is when lots of threads need to read the value of a shared variable, but only a few thread need to modify its value. (T/F)
TRUE (CORRECT)
Data races can be hard to identify because it is impossible to identify the potential for a data race. (T/F)
FALSE
The best use case for using a ReadWriteLock is when only a few threads need to modify the value of a shared variable. (T/F)
FALSE (CORRECT)
To avoid livelock, ensure that only one process takes action chosen by priority or some other mechanism, like random selection. (T/F)
TRUE (CORRECT)
ReentrantLock is a class that implements the Lock interface. (T/F)
TRUE (CORRECT)
The tryLock() method is useful because it enables a thread to execute alternate operations if the lock it needs to acquire is already taken. (T/F)
TRUE (CORRECT)
When a thread calls Java’s tryLock() method on a Lock that is NOT currently locked by another thread the method immediately returns true. (T/F)
TRUE (CORRECT)
Unlike during a deadlock, the threads in a livelock scenario are _____.
- END OF FA3-A3 = 20/20 -
actively executing without making useful progress (CORRECT)
- START OF FA3-A4 -
Only 1 thread can possess the ReadLock while another thread has a lock on the WriteLock. (T/F)
FALSE (CORRECT)
Protecting a critical section of code with mutual exclusion means only allowing authorized threads to execute the critical section. (T/F)
FALSE** (CORRECT)
Having too many concurrent threads can lead to starvation. (T/F)
TRUE (CORRECT)
A ReentrantLock can be locked by the same thread as many times depending on the operating system. (T/F)
FALSE (CORRECT)
A ReentrantLock can be locked multiple times by the same thread. (T/F)
TRUE (CORRECT)
How many times must a thread unlock a ReentrantLock before another thread can acquire it?
as many times as that thread locked it
A thread does not need to unlock a ReentrantLock before another thread can acquire it because multiple threads can lock a ReentrantLock at the same time. (T/F)
FALSE (CORRECT)
A possible strategy to resolve a livelock between multiple threads is thru implementing a randomized mechanism to determine which thread goes first. (T/F)
- END OF FA3- A4 = 18/20 -
*63 CORRECTED
TRUE (CORRECT)
- START OF FA3 - A5 -
There is no limit on the number of threads that can possess the ReadLock while another thread has a lock on the WriteLock. (T/F)
FALSE** (CORRECT)
What is the maximum number of threads that can possess the WriteLock of a ReentrantReadWriteLock at the same time?
1 (CORRECT)
Data races can be hard to identify because data races are caused by hardware errors and cannot be debugged in software. (T/F)
FALSE (CORRECT)
Using the ++ operator to increment a variable in Java executes as a single instruction at the lowest level. (T/F)
FALSE (CORRECT)
Using the ++ operator to increment a variable in Java executes as multiple instructions at the lowest level. (T/F)
TRUE (CORRECT)
Which of these is a possible strategy to resolve a livelock between multiple threads?
Group of answer choices
none of the mentioned
Implement a randomized mechanism to determine which thread goes first.
Patience because if you wait long enough all livelocks will eventually resolve themself.
Randomly terminate one of the threads involved in the livelock.
Implement a randomized mechanism to determine which thread goes first. (CORRECT)
A ReentrantLock can be locked once by multiple threads at the same time. (T/F)
- END OF FA3-A5 = 19/20 -
**70 CORRECTED
FALSE (CORRECT)
- START OF FA3-A6 -
In Java program, data race only occurs when each of the threads are incrementing a shared variable a large number of time because a data race can only occur when multiple threads are writing to a shared variable a large enough number of times. (T/F)
FALSE (CORRECT)
Protecting a critical section of code with mutual exclusion means preventing multiple threads from concurrently executing in the critical section. (T/F)
TRUE (CORRECT)
There is no limit on the number of threads that can possess a Lock at the same time. (T/F)
FALSE (CORRECT)
tryLock() will continuously try to acquire the lock if it is already taken by another thread. (T/F)
FALSE
Starvation occurs when a thread is unable to gain access to a necessary resource, and is therefore unable to make progress. (T/F)
TRUE (CORRECT)
When the threads in the program are not making progress, you can determine if it is due to a deadlock or a livelock by randomly guessing between deadlock and livelock. (T/F)
FALSE (CORRECT)
tryLock() includes built-in error handling so you do not need a separate try/catch statement. (T/F)
FALSE
The tryLock() method is useful because it includes built-in protection against common locking errors. (T/F)
FALSE (CORRECT)
Lock and ReentrantLock are two names for the same class. (T/F)
- END OF FA3-A6 = 20/20 -
FALSE
- START OF FA3-A7 -
Which of these scenario describes the best use case for using a ReadWriteLock?
Group of answer choices
Only a few threads need to both and modify the value of a shared variable.
Lots of threads need to modify the value of a shared variable, but only a few thread need to read its value.
Lots of threads need to read the value of a shared variable, but only a few thread need to modify its value.
Lots of threads need to both and modify the value of a shared variable.
Lots of threads need to read the value of a shared variable, but only a few thread need to modify its value.
Using the ++ operator to increment a variable in Java executes as an atomic instruction at the lowest level. (T/F)
FALSE (CORRECT)
Using the ++ operator to increment a variable in Java executes as _____ at the lowest level.
Group of answer choices
none of the mentioned
a single instruction
multiple instructions
an atomic instruction
multiple instructions (CORRECT)
The number of threads that can possess a Lock at the same time depends on the operating system. (T/F)
FALSE (CORRECT)
What does it mean to protect a critical section of code with mutual exclusion?
Group of answer choices
Only allow authorized threads to execute the critical section.
Whenever a thread enters the critical section pause all other threads in the program.
Prevent multiple threads from concurrently executing in the critical section.
Implement proper error handling techniques to catch any unexpected problems.
Prevent multiple threads from concurrently executing in the critical section.
How many threads can possess the ReadLock while another thread has a lock on the WriteLock?
Group of answer choices
0
1
no limit
2
0
The tryLock() method is useful because it enforces fairness among multiple threads competing for ownership of the same lock. (T/F)
FALSE
When the threads in the program are not making progress, you can determine if it is due to a deadlock or a livelock waiting to see if the problem eventually resolves itself. (T/F)
- END OF FA3-A7 = 20/20 -
FALSE (CORRECT)
- START OF FA3-A8 -
How many threads can possess a Lock at the same time?
Group of answer choices
no limit
2
0
1
1
Why can potential data races be hard to identify?
Group of answer choices
The problems that data races cause have an insignificant impact on the program’s performance.
It is impossible to identify the potential for a data race.
The data race may not always occur during execution to cause a problem.
Data races are caused by hardware errors and cannot be debugged in software.
The data race may not always occur during execution to cause a problem.
Deadlock occurs when each member of a group is waiting for some other member to take action, and as a result, neither member is able to make progress.
(T/F)
TRUE (CORRECT)
What happens when a thread calls Java’s tryLock() method on a Lock that is NOT currently locked by another thread?
Group of answer choices
The method will block until the Lock is available and then return false
The method will block until the Lock is available and then return true
The method immediately returns true
The method immediately returns false
The method immediately returns true (CORRECT)
Having too many concurrent threads may still not lead to starvation. (T/F)
- END OF FA3-A8 = 19/20 -
FALSE** (CORRECT)
- START OF FA3-A9 -
What is the maximum number of threads that can possess the ReadLock of a ReentrantReadWriteLock at the same time?
Group of answer choices
0
2
no limit
1
no limit (CORRECT)
When a thread calls Java’s tryLock() method on a Lock that is NOT currently locked by another thread the method immediately returns false. (T/F)
FALSE
Dining Philosophers Problem is a classic example that’s used to illustrate synchronization issues when multiple threads are competing for multiple locks. (T/F)
- END OF F3-A9 = 20/20 -
TRUE (CORRECT)
To lock a mutex multiple times, using a reentrant mutex may seem like an easy way to avoid a deadlock. (T/F)
TRUE (CORRECT)
A maximum of 2 threads can possess the WriteLock of a ReentrantReadWriteLock at the same time. (T/F)
FALSE (CORRECT)