Exam 2 Flashcards
The bare minimum number of cores and CPUs that are required to run a multithreaded program is…
One CPU with one core.
Calling the join() method on a running thread causes…
The join call blocks
Waiting for the thread to finish
If a thread has already finished running, then calling the join() method on the thread causes…
The thread is terminated normally without any issues.
When a thread is waiting to enter a critical section using a std::lock_guard, its CPU usage will be…
0%.
Given eight independent, shared resources, the optimal number of mutexes to maximize concurrent, thread-safe access to the eight resources is…
8.
A multithreaded program has four threads that run in parallel on four core machine. Each thread runs for two minutes. The total run time of the program would be…
Two minutes.
In order to use two resources protected by two mutexes m1 and m2, the preferred order of locking the mutex would be…
std::lock(m1, m2);
The most suitable command to copy a file named test.txt from a server named bkup.org would be…
scp bkup.org:test.txt
Given a C++ source file named exam2.cpp, the executable generated by compiling it must be named…
The executable can have any name.
The following C++ statement…
std::string a[] =
{“1”, “2”, “3”, “4”, “5”};
Creates an array of five string objects.
The minimum number of cores that are required to run a process with four threads (ignoring performance issues) would be…
One.
The minimum number of threads that are present in a standard process created by modern operating systems would be…
One.
The number of mutexes that are necessary to ensure MT-safe access to the SharedValue shown in the code fragment below would be…
const std::string
SharedValue = “12345”;
void threadMain() { // Code here }
Zero.
Which of the following resources are not shared between multiple threads…
CPU Registers.
Given an eight core CPU, the maximum number of threads that can be created in a single process is limited to…
Depends on the maximum threads supported by the Operating System.