Quiz questions Flashcards
Threads vs Processes – select all that apply:
a. Threads can easily share memory, although this can lead to complications when using thread programming.
c. Processes have their own private memory and are isolated.
d. Threads are owned by processes. Every process must have at least one thread.
The operating system is responsible for the order threads are scheduled to execute.
True
Main bottleneck of most programs is:
b. Accessing memory
Moore’s Law tells us several important things about computing.
b. In 1965, Gordon Moore predicted that the number of components on an integrated circuit would double every year or so.
f. Many have predicted the end of Moore’s law, although major chip manufacturers continue to see its effects.
Select all answers that are true about the cache.
a. More expensive
c. Temporary storage
d. Fast memory
What are the motivations for creating concurrent programs? Select all that apply.
a. Concurrent programs are better at sharing resources than sequential programs.
d. Concurrent programs are more responsive than sequential programs.
Non coherent cache is when one processor makes a change to a shared memory value, but the other processors are not aware of the change.
True
Select all statements that are true about inheritance:
c. The “is a” relationship occurs when one class inherits from another.
d. Multiple inheritance has a variety of problems, Java does not allow it but instead provides “workarounds”.
A critical section of code is:
b. An area of the code that is shared by multiple threads and one thread is writing to that location
Symmetric Multiprocessors (SMPs) use a shared memory design.
b. SMPs are easier to program than other processor designs in part because they use shared memory.
d. Memory sharing means that all processors can see the same block of memory, this is implemented by hardware in SMPs.
Graphical Processing Units (aka GPUs) originally designed for games now have a variety of other uses.
a. A GPU is able to execute thousands of simple repetitive tasks in parallel, it accomplishes this with 100s of very simple processing units, sometimes referred to as a SIMD or Vector processor.
d. GPUs are often implemented with their own dedicated on board memory. 8GB is typical in 2024, although some have much more memory than this.
The benefits of using the interface, Runnable, over extends Thread in Java are: (Select all that apply)
a. Can implement many interfaces
c. Only requires one method to be implemented (run)
d. Allows for shared memory between threads
If you leave out the join method in a program that creates threads, the program will never finish executing.
False
Select 2 reasons why a thread may be in a waiting state.
a. Waiting for input
c. Waiting for data from memory
Which of the following is not a state in the Thread state enumeration in Java.
d. Running
Logical Cores vs. Physical Cores, select all that apply
b. A Physical Core may have one or more logical cores.
Data races and cache coherency are…
c. Two similar problems that can be solved in some cases with a synchronized method.
d. Both problems which if not handled properly can lead to incorrect results.
Semaphores can be used to communicate between threads. This is useful because…
a. … there are several synchronization problems that requires threads to be coordinated. A single thread can thus lead, or signal other threads that it is their turn.
d. … there are several synchronization problems that requires threads to be coordinated. A pair of threads can pass a signal back and forth, forcing serialization.
Select which of the following are atomic types in Java. (Select all that apply)
b. AtomicInteger
c. AtomicBoolean
ReentrantLocks are more general than some primitives and less general than other primitives. Select true examples in the following cases:
a. Atomic Integers can be manually implemented with Reentrant Locks.
c. Anything that can be done with a synchronized method can be done with a ReentrantLock.
The 2nd Assignment suggests that you use CyclicBarriers, identify some true statements about them:
a. A CyclicBarrier allows multiple threads to synchronize, meaning that they can block until each thread reaches the same line in the code.
d. A CyclicBarrier, as the name implies, can repeat its action over several trials.
When a thread tries to obtain a lock on a Reentrant Lock and is unsuccessful, it is put back into the Runnable state to do other work.
False
ReentrantLock class in Java provides the following method to protect a critical section. Select all that apply.
a. lock
b. unlock
The Readers and Writers problem …
b. … is a common problem encountered by databases, and if solved correctly, will allow multiple readers to concurrently access the database
c. … is a common problem encountered by databases, which for example are searched more frequently than they are updated.
e. … occurs when you have several readers and only one writer. A special lock mechanism is provided for this unusual case.
Regarding the last instructions sent to a Thread Pool…
d. We had some difficulty demonstrating awaitTermination() in class, this method is suppose to do something like the .join() method for regular threads.