1/37
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What does the POSIX threads API add to Unix?
Threading capabilities.
What are POSIX threads commonly referred to as?
Pthreads.
What is the basic unit of concurrency in POSIX threads?
Thread.
What function is used to create a thread in Pthreads?
pthread_create().
What does the pthread_create() function require as an argument?
Start function and argument.
What is the type used for declaring a thread in Pthreads?
pthread_t.
What kind of object is the thread attribute in pthread_create()?
pthread_attr_t.
What are the possible ways that POSIX threads can terminate?
Exiting the application, calling pthread_exit(), or returning from the start function.
What is the purpose of pthread_join()?
To wait for a thread to finish and to retrieve its exit status.
What is a mutex used for in POSIX threads?
To ensure mutual exclusion when accessing shared data.
How can a mutex be initialized in POSIX threads?
Using PTHREAD_MUTEX_INITIALIZER or pthread_mutex_init().
What is a function that will try to lock a mutex?
pthread_mutex_trylock().
What happens when you destroy a mutex that is currently locked?
It results in an error.
What is the behavior of the default mutex regarding recursive locks?
It may not allow recursive locks.
What type of variable works with mutexes for signaling between threads?
Condition variables.
What is the function used to wait on a condition variable?
pthread_cond_wait().
What method is used to signal a single waiting thread?
pthread_cond_signal().
What happens if you signal a condition variable with no waiting threads?
Nothing occurs.
What is the purpose of POSIX semaphores?
To control access to shared resources between processes or threads.
How do you initialize a POSIX semaphore?
By using sem_init().
What operation corresponds to the sem_wait() function?
P() operation in Dijkstra’s semaphore notation.
What does sem_post() correspond to in semaphore operations?
V() operation in Dijkstra’s semaphore notation.
What is the result of calling sem_trywait() on a semaphore that's not available?
It returns EAGAIN.
Where are POSIX semaphores declared?
In semaphore.h.
What is the primary difference between POSIX semaphores and System V semaphores?
POSIX semaphores are considered an improvement and obsolete System V semaphores.
What header file is required for working with Pthreads?
pthread.h.
What happens to waiting threads when a condition variable is signaled?
The sleeping threads are awakened.
What function can be used to destroy a condition variable?
pthread_cond_destroy().
What is one key requirement for using a condition variable?
A thread must hold a mutex to wait on it.
Which function creates a condition variable?
pthread_cond_init().
What is a potential risk when destroying a condition variable?
Doing so while there are waiting threads is an error.
What is the typical behavior of a condition variable across different Pthreads implementations?
It typically has no attributes recognized by Linux.
What is a unique feature of recursive mutexes?
They maintain a lock count.
What does pthread_cond_broadcast() do?
Signals all waiting threads.
What is the return type of a thread start function?
void*.
What should you check before destroying a mutex or condition variable?
Ensure no threads are using or waiting on it.
What is the role of pthread_attr_t in thread management?
To specify various thread attributes like scheduler and stack size.
What is indicated by the term 'deadlock'?
A situation where two or more threads cannot proceed because each is waiting for the other to release resources.