COSC 4302 Final

Ace your homework & exams now with Quizwiz!

Which of the following is true about the two versions of readers-writers problem? A) In the first readers-writers problem, a writer may starve if a continuous series of readers arrive before the earlier readers exit their critical section. B) In the second readers-writers problem, a reader may starve if a continuous series of readers arrive before the earlier readers exit their critical section. C) In the first readers-writers problem, a writer may starve if a continuous series of writers arrive before the earlier writers exit their critical section. D) In the second readers-writers problem, a writer may starve if a continuous series of readers arrive before the earlier readers exit their critical section.

A) In the first readers-writers problem, a writer may starve if a continuous series of readers arrive before the earlier readers exit their critical section.

Which of the following is NOT true regarding semaphore implementation? A) It suffers from the busy waiting problem B) Semaphore has a waiting queue associated with the semaphore C) When a process executes the wait() operation and finds that the semaphore value is not positive, it will suspend itself D) A process that is suspended, waiting on the semaphore, should be restarted when some other process executes a signal() operation.

A) It suffers from the busy waiting problem

Which of the following is a software-based solution to the critical-section problem? A) Peterson's solution B) test_and_set C) compare_and_swap D) all of the above

A) Peterson's solution

In the structure of the producer process shown in Figure 7.1, what would be a possible outcome if wait(empty) is replaced with signal(empty) and signal(full) is replaced with wait(full)? A) Producer will remain blocked after adding an item in the buffer. B) Consumer will remain blocked after taking out an item from the buffer. C) Producer and consumer may access the buffer at the same time. D) All of the above.

A) Producer will remain blocked after adding an item in the buffer.

Which of the following is NOT true? A) Since semaphore and mutex lock are tools for synchronization, process that have used semaphores or mutex locks should not cause deadlocks B) Semaphores and mutex locks may be shared resources that difference processes contend for, and hence deadlocks may occur C) a set of processes is in a deadlocked state when every process in the set is waiting for an event that can be caused only by another process in the set D) all of the above

A) Since semaphore and mutex lock are tools for synchronization, process that have used semaphores or mutex locks should not cause deadlocks

In a system resource-allocation graph, ____. A) a directed edge from a resource to a process is called an assignment edge B) a directed edge from a resource to a process is called a request edge C) a directed edge from a process to a resource is called an assignment edge D) None of the above

A) a directed edge from a resource to a process is called an assignment edge

5. In _________, the process requests permission to access and modify variables shared with others. A) entry section B) critical section C) exit section D) remainder section

A) entry section

Which of the following indicates that Pi can enter the critical section in Peterson's solution? A) flag[j] == false or turn == i B) flag[j] == true or turn == i C) flag[j] == false or turn == j D) flag[j] == true and turn == j

A) flag[j] == false or turn == i

Critical-section compiler directive in OpenMP is generally considered easier to use than standard mutex locks, because A) management of entry and exit code is managed by OpenMP library reducing the possibility of programming errors. B) programmers don't need to worry about race conditions. C) a thread cannot block inside a critical section. D) deadlock cannot occur.

A) management of entry and exit code is managed by OpenMP library reducing the possibility of programming errors.

A thread using POSIX condition variables, a thread A) must lock the associated mutex lock before calling pthread_cond_wait( ) and unlock it after calling pthread_cond_signal( ). B) must lock the associated mutex lock before calling pthread_cond_wait( ), but doesn't need to unlock it after calling pthread_cond_signal( ). C) doesn't need to lock the associated mutex lock before calling pthread_cond_wait( ), but must unlock it after calling pthread_cond_signal( ). D) doesn't need to lock the associated mutex lock before calling pthread_cond_wait( ) and doesn't need to unlock it after calling pthread_cond_signal( ).

A) must lock the associated mutex lock before calling pthread_cond_wait( ) and unlock it after calling pthread_cond_signal( ).

Which of the following regarding mutex lock is NOT true? A) mutex lock is a hardware solution to critical-section problem B) mutex lock is a higher-level software solution to critical-section problem C) mutex lock suffers from busy waiting D) the general rule of thumb is to use a mutex lock if the lock will be held for a duration less than two context switches

A) mutex lock is a hardware solution to critical-section problem

Which of the following critical-section problem's requirements ensures only one process is active in its critical section at a time? A) mutual exclusion B) progress C) bounded waiting D) none of the above

A) mutual exclusion

A notify( ) operation in Java monitors A) removes a process from the wait set and puts it in the entry set. B) removes a process from the entry set and puts it in the wait set. C) removes a process from the entry set and provides the lock for the object to that process. D) removes a process from the wait set and provides the lock for the object to that process.

A) removes a process from the wait set and puts it in the entry set.

When mutex lock is implemented as a binary semaphore, what should its value be initialized to be? A) 0 B) 1 C) -1 D) none of the above

B) 1

Which of the following statements is not true about spinlocks in Linux? A) Spinlocks cannot be used on single processor machines. B) A thread may disable kernel preemption on Symmetric Multi Processing machines instead of acquiring spinlocks. C) A thread that acquires a spinlock cannot acquire the same lock a second time without first releasing the lock. D) The Linux kernel is designed so that the spinlock is held only for only short durations.

B) A thread may disable kernel preemption on Symmetric Multi Processing machines instead of acquiring spinlocks.

10. Which of the following is true for the solutions to critical-section problems? A) No deadlock implies progress, and progress implies bounded waiting B) Bounded waiting implies progress, and progress implies no deadlock C) Progress implies no deadlock, and no deadlock implies bounded waiting D) Bounded waiting implies no deadlock, and no deadlock implies progress

B) Bounded waiting implies progress, and progress implies no deadlock

In the deadlock example shown in Figure 8.1, A) a deadlock is guaranteed to occur. B) a deadlock may occur sometime, but not necessarily every time. C) a deadlock may occur sometime only if there are more than one instances of thread_one and thread_two are running. D) a deadlock is guaranteed to occur as long as there are more than one instances of thread_one and thread_two are running.

B) a deadlock may occur sometime, but not necessarily every time.

In the livelock example shown in Figure 8.2, A) a livelock is guaranteed to occur. B) a livelock may occur sometime. C) a livelock may occur sometime only if there are more than one instances of thread_one and thread_two are running. D) a livelock is guaranteed to occur as long as there are more than one instances of thread_one and thread_two are running.

B) a livelock may occur sometime.

A key difference between Reentrant locks and JAVA monitor's synchronized statements is that A) there is a possibility of deadlock when using a monitor while deadlock cannot occur when using reentrant locks. B) a reentrant lock favors granting the lock to the longest-waiting thread while there is no specification for the order in which threads in the wait set for an object lock. C) multiple processes may own a reentrant lock at the same time while at most one process may execute inside a synchronized method at any time. D) at most one process may own a reentrant lock, while multiple processes may execute inside a synchronized method at any time.

B) a reentrant lock favors granting the lock to the longest-waiting thread while there is no specification for the order in which threads in the wait set for an object lock.

In the solution for bounded buffer problem using JAVA monitors (Figure 7.9), functions insert( ) and remove( ) are synchronized to ensure that A) a thread may insert an item and different thread may remove an item from a different location in the buffer simultaneously. B) at most one thread may enter or remove an item at any time. C) at most one thread may enter an item at any time, but multiple threads may remove items from different locations at the same time. D) multiple thread may enter items at different locations at the same time, but at most one thread may remove an item at the same tim

B) at most one thread may enter or remove an item at any time.

In _________, the process may be changing common variables, updating a table, writing a file, and so on. A) entry section B) critical section C) exit section D) remainder section

B) critical section

In a single processor system running Windows, when the kernel accesses a global resource, it A) uses spinlocks. B) masks all interrupts. C) uses a dispatcher object. D) atomic integers.

B) masks all interrupts.

One necessary condition for deadlock is ____, which states that at least one resource must be held in a nonsharable mode. A) hold and wait B) mutual exclusion C) circular wait D) no preemption

B) mutual exclusion

Which of the following critical-section problem's requirements ensures programs will cooperatively determine what process will next enter its critical section? A) mutual exclusion B) progress C) bounded waiting D) none of the above

B) progress

The signal( ) operation in the example using JAVA condition variables ensures that the thread with the thread number turn A) that is blocked on await( ) is unblocked. B) that may be blocked on await( ) is unblocked. C) does not block on await( ) even if hasn't yet called this function. D) blocks on await( ) if it hasn't yet called this function.

B) that may be blocked on await( ) is unblocked.

Alternate approaches such as transactional memory or OpenMP are useful, because A) some race condition problems that cannot be solved using synchronization mechanisms such as mutex locks and semaphores can be solved using these alternate approaches. B) these approaches scale much better than synchronization mechanisms such as mutex locks and semaphores as the number of threads increases. C) developers do not need to identify race conditions when using these approaches. D) All of the above.

B) these approaches scale much better than synchronization mechanisms such as mutex locks and semaphores as the number of threads increases.

Which of the following is true? A) No deadlock implies no starvation; B) No starvation implies no deadlock; C) Deadlock doesn't imply starvation; D) Starvation implies deadlock.

C) Deadlock doesn't imply starvation;

Which of the following statements is true? A) A counting semaphore can never be used as a binary semaphore. B) A binary semaphore can never be used as a counting semaphore. C) Spinlocks can be used to prevent busy waiting in the implementation of semaphore. D) Counting semaphores can be used to control access to a resource with a finite number of instances.

C) Spinlocks can be used to prevent busy waiting in the implementation of semaphore.

In a system resource-allocation graph, ____. A) a directed edge from a process to a resource is called an assignment edge B) a directed edge from a resource to a process is called a request edge C) a directed edge from a process to a resource is called a request edge D) None of the above

C) a directed edge from a process to a resource is called a request edge

In the monitor solution for dining-philosophers problem (Figure 7.7), a philosopher may start eating A) at the end of the pickup( ) function before exiting the function. B) in the beginning of the putdown( ) function C) after exiting the pickup( ) function and before entering the putdown( ) function. D) All of the above.

C) after exiting the pickup( ) function and before entering the putdown( ) function.

Atomic integers in Linux are useful when A) several variables are involved in a race condition. B) a single process access several variable involved in a race condition. C) an integer variable needs to be updated. D) All of the above.

C) an integer variable needs to be updated.

5. In an asymmetric solution for the dining philosophers problem, deadlock is avoided, because A) there is no contention for acquiring chopsticks. B) neighboring philosophers will never get hungry at the same time. C) any neighboring philosophers would have already acquired one of their chopsticks before attempting to acquire the shared chopstick. D) a philosopher will release a chopstick in case she is unable to acquire the other chopstick.

C) any neighboring philosophers would have already acquired one of their chopsticks before attempting to acquire the shared chopstick.

Assume the binary variable lock is initialized to be 0, which of the following can be an implementation of the entry section to solve the critical-section problem? A) while (compare and swap(&lock, 0, 1) != 0), do nothing; B) while (test and set(&lock)), do nothing; C) both A and B D) none of the above

C) both A and B

2. Which of the following is true for race condition? A) race condition occurs where several processes access and manipulate the same data concurrently B) when race condition occurs, the outcome of the execution depends on the particular order in which the access takes place C) both of the above D) none of the above

C) both of the above

Which of the following actions should be performed among cooperating processes? A) process synchronization B) coordination C) both of the above D) none of the above

C) both of the above

Which of the following variables are shared between the processes in Peterson's solution? A) int turn B) boolean flag[2] C) both of the above D) none of the above

C) both of the above

Which of the following critical-section problem's requirements limits the amount of time a program will wait before it can enter its critical section? A) mutual exclusion B) progress C) bounded waiting D) none of the above

C) bounded waiting

Which of the following is true regarding the requirements for the solutions to critical-section problem? A) mutual exclusion implies progress B) progress implies bounded waiting C) bounded waiting implies progress D) none of the above

C) bounded waiting implies progress

One necessary condition for deadlock is ______, which states that there is a chain of waiting processes whereby P0 is waiting for a resource held by P1, P1 is waiting for a resource held by P2, and Pn is waiting for a resource held by P0. A) hold and wait B) mutual exclusion C) circular wait D) no preemption

C) circular wait

Under which of the following contention loads does traditional synchronization become faster than CAS-based synchronization? A) uncontended B) moderate contention C) high contention D) none of the above

C) high contention

A(n) ___________ is a sequence of read-write operations that are atomic. A) atomic integer B) semaphore C) memory transaction D) mutex lock

C) memory transaction

When the state for a dispatcher object moves to signaled, the Windows kernel A) moves all threads waiting on that object to ready state if the dispatcher object is a mutex object. B) moves a fixed number of threads (possibly greater than one) waiting on that object to ready state if the dispatcher object is a mutex object. C) moves all threads waiting on that object to ready state if the dispatcher object is an event object. D) moves a fixed number of threads (possibly greater than one) waiting on that object to ready state if the dispatcher object is an event object.

C) moves all threads waiting on that object to ready state if the dispatcher object is an event object.

The counting semaphore is initialized to ___________. A) 0 B) 1 C) the number of resources available D) none of the above

C) the number of resources available

In JAVA, when a thread calls wait( ) inside a synchronized method, A) the thread releases the object lock and continues its execution. B) the thread releases the object lock, blocks and is put in the entry set. C) the thread releases the object lock, blocks and is put in the wait set. D) the thread continues its execution without releasing the object lock.

C) the thread releases the object lock, blocks and is put in the wait set.

What is the correct order of operations for protecting a critical section using a binary semaphore? A) release() followed by acquire() B) acquire() followed by release() C) wait() followed by signal() D) signal() followed by wait()

C) wait() followed by signal()

An advantage of using transactional memory is that A) the atomicity is guaranteed by the transactional memory system. B) there is no possibility of deadlocks. C) the transactional memory system can identify which statements in atomic blocks can be executed concurrently. D) All of the above.

D) All of the above.

In functional programming languages, A) race conditions cannot occur. B) there is no need to maintain program state. C) deadlocks cannot occur. D) All of the above.

D) All of the above.

POSIX named semaphores A) can easily be used by multiple unrelated processes. B) can be initialized during creation time. C) uses sem_wait( ) and sem_post( ) to acquire and release a semaphore respectively. D) All of the above.

D) All of the above.

A difference between software transactional memory (STM) and hardware transactional memory (HTM) is that A) HTM uses cache hierarchy and cache coherency protocols while STM uses software implementation in addition to the cache hierarchy and cache coherency protocols. B) STM requires no special code instrumentation and thus has less overhead than HTM. C) In HTM, code is inserted by a compiler, while in STM, user enters the appropriate code. D) HTM requires existing cache hierarchies and cache coherency protocols be modified, while STM does not.

D) HTM requires existing cache hierarchies and cache coherency protocols be modified, while STM does not.

Which of the following is NOT true regarding conditional variable, e.g. x? A) The only operations that can be invoked on a condition variable are wait() and signal() B) x.wait() means that the process invoking this operation is suspended until another process invokes x.signal() C) The x.signal() operation resumes exactly one suspended process D) If no process is suspended, then the signal() operation still affects the state of the semaphore

D) If no process is suspended, then the signal() operation still affects the state of the semaphore

A critical-section object in Windows A) is particularly efficient when there is lots of contention for the object. B) completely avoids kernel intervention. C) uses spinlocks on single processor systems. D) None of the above.

D) None of the above.

Which of the following is NOT true for Peterson's solution? A) Mutual exclusion is preserved B) The progress requirement is satisfied C) The bounded-waiting requirement is met D) Peterson's solution works for synchronization among more than two processes

D) Peterson's solution works for synchronization among more than two processes

Which of the following is not true about test_and_set instruction? A) It is a hardware instruction B) It is executed atomically C) Returns the original value of passed parameter D) Returns the new value of passed parameter

D) Returns the new value of passed parameter

Which of the following is not true about compare_and_swap instruction? A) It is a hardware instruction B) It is executed atomically C) Returns the original value of passed parameter D) Set the new value of passed parameter to "TRUE"

D) Set the new value of passed parameter to "TRUE"

Which of the following are efforts to towards developing scalable, efficient tools that address the demands of concurrent programming? A) designing compilers that generate more efficient code B) developing languages that provide support for concurrent programming C) improving the performance of existing libraries and APIs D) all of the above

D) all of the above

Which of the following may cause a liveness failure? A) an infinite loop B) a busy waiting loop C) a deadlock D) all of the above

D) all of the above

Which of the following solutions needs hardware support for the critical section problem? A) memory barriers B) compare_and_swap instruction C) atomic variables D) all of the above

D) all of the above

In the solution provided for readers-writers problem in Section 7.1.2, if a writer is in the critical section, and multiple readers and writers are waiting, A) all waiting readers will be allowed to enter the critical section when the writer in the critical section exits. B) all waiting writers will be allowed to enter the critical section when the writer in the critical section exits. C) exactly one of the waiting writers will be allowed to enter the critical section when the writer in the critical section exits. D) either all waiting readers or exactly one writer will be allowed to enter the critical section.

D) either all waiting readers or exactly one writer will be allowed to enter the critical section.

One necessary condition for deadlock is ______, which states that a resource can be released only voluntarily by the process holding the resource. A) hold and wait B) mutual exclusion C) circular wait D) no preemption

D) no preemption

Assume count is a variable name, which of the following operations is atomic? A) count++ B) count-- C) both of the above D) none of the above

D) none of the above

A reader-writer lock is useful when A) there are a significantly large number of processes attempting to enter a critical section. B) there are a significantly large number of consumer processes attempting to read data from a bounded buffer. C) there are a significantly small number of reader processes attempting to read in the critical section. D) there are a significantly large number of reader processes attempting to read in the critical section.

D) there are a significantly large number of reader processes attempting to read in the critical section.

Emergence of multicore systems has put greater emphasis on developing novel techniques for concurrency problems, because A) some fundamentally new concurrency problems have arisen that cannot be solved using traditional techniques such as mutex locks, semaphores, and monitors. B) race conditions are much more difficult to solve in multicore systems. C) deadlocks are much more difficult to prevent or avoid in multicore systems. D) with increased number of processing cores, there is an increased risk of race conditions and deadlocks.

D) with increased number of processing cores, there is an increased risk of race conditions and deadlocks.

A call to pthread_cond_signal() (used by POSIX threads, called Pthread) releases the associated mutex lock.

False

A critical section object in the user mode needs kernel intervention to ensure mutual exclusion.

False

A monitor is an abstract data type that is based on semaphore implementation.

False

A mutex lock is released immediately after entering a critical section.

False

A reader-writer lock gives preference to writer processes in the readers-writers problem.

False

A solution to the readers-writers problem that avoids starvation and allows some concurrency among readers is not possible.

False

CAS-based synchronization is always faster than traditional synchronization.

False

Each critical section must be assigned a different name in OpenMP.

False

If a thread has the ownership of a Reentrant lock, it will block forever if it calls lock( ) before calling unlock( ).

False

In JAVA, calling a synchronized method always blocks the calling thread.

False

In Windows, a thread may get preempted while holding a spinlock.

False

JAVA provides support for both named and unnamed condition variables.

False

Mutex locks and counting semaphores are essentially the same thing.

False

Peterson's solution works on modern computer architectures.

False

The value of a counting semaphore can range only between 0 and 1.

False

When the mutex lock is implemented based on a binary semaphore, it should be initialized to be 0.

False

A semaphore has an integer value.

True

Allowing at most four philosophers to sit simultaneously prevents deadlock.

True

Bounded waiting implies progress, and progress implies mutual exclusion.

True

Dining philosophers problem is important because it represents a class of problems where multiple processes need to share multiple resources.

True

Dispatcher objects in Windows are used for synchronization outside the kernel.

True

Every object in Java has associated with it a single lock.

True

Mutex lock variable is binary.

True

POSIX unnamed semaphores can be shared either only by threads with in a single process, or between processes.

True

Race conditions can result in corrupted values of shared data.

True

Semaphore implementation overcomes the busy waiting problem.

True

Semaphores and mutex locks both provide mutual exclusion.

True

Semaphores in JAVA can be initialized to a negative value.

True

Solutions to the critical section problem may suffer from liveness failures.

True

Spinlocks are not appropriate for single-processor systems.

True

The preemptive kernel is more suitable for real-time programming than non-preemptive kernel.

True

The preemptive kernel may be more responsive than non-preemptive kernel.

True

The solution for bounded buffer problem provided in Section 7.1.1 does not work correctly if there are more than one producer or consumer.

True

To lock the kernel on a single processor machine in Linux, kernel preemption is disabled.

True

Transactional memory may particularly be useful for multicore systems.

True

With reentrant locks, programming construct try and finally is used to ensure that unlock( ) is called even when an exception occurs in the critical section.

True

Assume you had a function named update() that updates shared data. Illustrate how a mutex lock named mutex might be used to prevent a race condition in update().

void update() { mutex.acquire(); // update shared data mutex.release(); }

Write two short methods that implement the simple semaphore wait() and signal() operations on global variable S.

wait (S) { while (S <= 0); S--; } signal (S) { S++; }


Related study sets

EMT Ch 3: Lifting and Moving Patients

View Set

Chapter 13: Solving the DC Series-Parallel Circuit

View Set

Silvestri NCLEX Questions (EXAM 2)

View Set

unit 7 - green factories - test #7 quizlet

View Set

Gaurunteed exam missed questions

View Set

Data Analytics in Accounting and Business

View Set