Quiz 7 APUE11

¡Supera tus tareas y exámenes ahora con Quizwiz!

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.

___ 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.

Barrier

Which of the following items is shared by all thread in a process?

File descriptors

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?

The process runs this function for the thread being terminated.

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.

While a thread reads a variable, there is no consistency problem.

pthread_join function acts as ___ to allow one thread to wait until another thread exits.

barrier

A ___ is basically a lock that a thread does set (lock) before accessing a shared resource and release (unlock) when we're done.

mutex

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.

nonpreemptive

Spin locks are useful when running in real-time scheduling class that doesn't allow ____.

preemption

A thread can arrange for functions to be called when it exits, similar to the way that the atexit function.

pthread_cleanup_push

What is a thread primitive, corresponding to fork for process.

pthread_create

Which of the following functions is used to create a thread?

pthread_create

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

Which of the following functions is used by a thread to terminate itself?

pthread_exit

What is a thread primitive, corresponding to waitpid for process.

pthread_join

Which of the following functions is used to wait for a thread or threads to terminate?

pthread_join

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);

Which of the following functions is used by a thread to obtain its ID?

pthread_self

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?

rc = pthread_create(&tid, NULL, PrintHello, (void *)1);

___ 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.

spin-lock

Spin locks are often used as low-level primitives to implement other types of locks, and can be implemented efficiently using ___ instruction.

test-and-set

If any thread within a process calls exit, _Exit, or _exit, then what is expected?

the entire process (with all of its threads) terminates.


Conjuntos de estudio relacionados

Chap. 4: Evidence-Based Practice & Ethics

View Set

1=a 2=b 3=c 4=d 5=e 6=f 7=g 8=h 9=i 10=j 11=k 12=l 13=m 14=n 15=o 16=p 17=q 18=r 19=s 20=t 21=u 22=v 23=w 24=x 25=y 26=z

View Set

6. Vitamin D requirements of older adults

View Set

end products of cellular respiration

View Set

PE172 Ch 12 Achieving a Health Weight

View Set

NU245- Chapter 18: Personality Disorders

View Set

psychology of aging midterm questions

View Set

Med-Surg Chapter 30-heme-Good with EXP 160ish Q

View Set

Chapter 4 The Monetary System: What it Is and How it Works

View Set