Week11 Quiz - Thread

[APUE11&12] Which of the following items is shared by all thread in a process?
Stack
Program Counter
File descriptors
Errno variable
[APUE11&12] If a thread knows that no thread cares about its return value, then which of the following functions does it call to indicate that resources associated with it can be released on termination?
Pthread_detach
Pthread_exit
Pthread_join
Pthread_self
Pthread_create
Pthread_equal
Pthread_terminate
Pthread_release
Pthread_new
Pthread_kill
[APUE11&12] Spin locks are often used as low-level primitives to implement other types of locks, and can be implemented efficiently using ___ instruction.
Atomic
Swap-and-set
Test-and-set
Spin-and-set
Mutual-exclusive
[APUE11&12] Consider the following statements for a lock in thread programming. pthread_mutex_t MutexLock; pthread_mutex_init(&MutexLock, NULL); Which of the following statement will lock the mutex called MutexLock?
Pthread_mutex_lock(&MutexLock);
Pthread_mutex_init(&MutexLock);
Pthread_lock(&MutexLock);
Pthread_mutexlock(&MutexLock);
Pthread_lock(*MutexLock);
[APUE11&12] Spin locks are useful when running in real-time scheduling class that doesn’t allow ____.
Preemption
Single thread of control
Reentrant processes
Concurrency
Mutex
Time-sharing
[APUE11&12] Which of the following functions is used by a thread to terminate itself?
Pthread_detach
Pthread_exit
Pthread_join
Pthread_self
Pthread_create
Pthread_equal
Pthread_terminate
Pthread_release
Pthread_new
Pthread_kill
[APUE11&12] Which of the following functions is used to create a thread?
Pthread_detach
Pthread_exit
Pthread_join
Pthread_self
Pthread_create
Pthread_equal
Pthread_terminate
Pthread_release
Pthread_new
Pthread_kill
[APUE11&12] When multiple threads of control share the same memory (a shared variable), one needs to make sure that each thread sees a consistent view of its data. Which of the following statements is not correct? Select one best answer.
If each thread uses variables while other threads don’t read or modify, no consistency problems will exist.
If a shared variable is read-only, there is no consistency problem.
When a thread can modify a variable that other threads can read or modify, then inconsistency problem can occur.
While a thread reads a variable, there is no consistency problem.
[APUE11&12] Which of the following functions is used by a thread to obtain its ID?
Pthread_detach
Pthread_exit
Pthread_join
Pthread_self
Pthread_create
Pthread_equal
Pthread_terminate
Pthread_release
Pthread_new
Pthread_kill
[APUE11&12] When the default action initialed by a thread is to terminate the process of this thread, what is expected?
A signal sent to a thread will terminate the entire process.
A signal sent to the process will terminate all the threads of the process.
A signal sent to a thread to be terminated but it is ignored by the process.
This is an invalid action which a thread cannot initiate.
[APUE11&12] Spin locks are useful when used in a(n) ___ kernel: besides providing a mutual exclusion mechanism, they block interrupts so an interrupt handler can’t deadlock the system by trying to acquire a spin lock that is already locked.
Preemptive
Nonpreemptive
Reentrant
Nonretentrant
Concurrent
Time-sharing
[APUE11&12] What is a thread primitive, corresponding to waitpid for process.
Pthread_create
Pthread_exit
Pthread_join
Pthread_cleanup_push
Pthread_self
Pthread_cancel
[APUE11&12] Consider the following function to be run by a thread. void *PrintHello(void *threadid) { . . . } pthread_t tid; int rc; Which of the following statement is correct to create a thread that executes a function called PrintHello?
Pthread_init(&tid, NULL, PrintHello, (void *)1);
Pthread_create(tid, NULL, *PrintHello, 1);
Pthread_create(&tid, NULL, &PrintHello, (void *)1);
Pthread_create(&tid, NULL, PrintHello, (void *)1);
Pthread_new(&tid, NULL, PrintHello, 1);
[APUE11&12] What is a thread primitive, corresponding to fork for proces.
Pthread_create
Pthread_exit
Pthread_join
Pthread_cleanup_push
Pthread_self
Pthread_cancel
[APUE11&12] When a thread is terminated, a thread can arrange for a function to be called when it exits. Which of the following statement is not correct?
This function is known as thread cleanup handler.
More than one function can be established and registered for a thread for its exit.
This function is recorded in a stack
This function will be xecuted (in reverse order, if more than one, of the registration).
The process runs this function for the thread being terminated.
[APUE11&12] If any thread within a process calls exit, _Exit, or _exit, then what is expected?
The thread called exit will terminate.
The thread and its children will terminate.
The entire process (with all of its threads) terminates.
No effect to the thread as exit is only for process.
[APUE11&12] ___ is a synchronization mechanism that can be used to coordinate multiple threads working in parallel. This allows each thread to wait until all cooperating threads have reached the same point, and then continue executing from there.
Lock
Mutex
Conditional variable
Spin lock
Barrier
Semaphore
[APUE11&12] What is a thread primitive, corresponding to atexit for proces.
Pthread_create
Pthread_exit
Pthread_join
Pthread_cleanup_push
Pthread_self
Pthread_cancel
[APUE11&12] ___ is like a mutex, except that instead of blocking a process by sleeping, the process is blocked by busy-waiting until the lock can be acquired.
Simple-lock
Busy-mutex
Wait-lock
Conditional variable
Spin-lock
[APUE11&12] Which of the following functions is used to wait for a thread or threads to terminate?
Pthread_detach
Pthread_exit
Pthread_join
Pthread_self
Pthread_create
Pthread_equal
Pthread_terminate
Pthread_release
Pthread_new
Pthread_kill
[APUE11&12] A ___ is basically a lock that a thread does set (lock) before accessing a shared resource and release (unlock) when we’re done.
Bit-lock
Mutex
Conditional variable
Semaphore
Message queue
[APUE11&12] pthread_join function acts as ___ to allow one thread to wait until another thread exits.
Lock
Mutex
Conditional variable
Spin lock
Barrier
Semaphore
{"name":"Week11 Quiz - Thread", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"[APUE11&12] Which of the following items is shared by all thread in a process?, [APUE11&12] If a thread knows that no thread cares about its return value, then which of the following functions does it call to indicate that resources associated with it can be released on termination?, [APUE11&12] Spin locks are often used as low-level primitives to implement other types of locks, and can be implemented efficiently using ___ instruction.","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}
Powered by: Quiz Maker