Explore tens of thousands of sets crafted by our community.
Shared Memory Programming with Pthreads
26
Flashcards
0/26
pthread_exit()
Purpose: To terminate the calling thread and optionally return a value to a joining thread. Basic Usage Example: pthread_exit(NULL);
pthread_equal()
Purpose: To compare two thread identifiers. Basic Usage Example: if (pthread_equal(thread1, thread2)) { /* Do something */ }
pthread_once()
Purpose: To ensure that a piece of initialization code is executed only once. Basic Usage Example: pthread_once(&once_control, init_routine);
pthread_detach()
Purpose: To detach a thread, indicating that it should not be joined. Basic Usage Example: pthread_detach(thread);
pthread_cleanup_pop()
Purpose: To remove the most recently installed cleanup handler. Basic Usage Example: pthread_cleanup_pop(execute);
pthread_join()
Purpose: To block the calling thread until the specified thread terminates. Basic Usage Example: pthread_join(thread, NULL);
pthread_cond_signal()
Purpose: To unblock at least one of the threads that are blocked on the specified condition variable. Basic Usage Example: pthread_cond_signal(&cond);
pthread_cond_wait()
Purpose: To block a thread until a specific condition is signaled. Basic Usage Example: pthread_cond_wait(&cond, &mutex);
pthread_attr_destroy()
Purpose: To destroy thread attributes and free any resources. Basic Usage Example: pthread_attr_destroy(&attr);
pthread_key_delete()
Purpose: To delete a thread-specific data key. Basic Usage Example: pthread_key_delete(key);
pthread_create()
Purpose: To create a new thread. Basic Usage Example: pthread_create(&thread, NULL, &function, NULL);
pthread_cleanup_push()
Purpose: To register a cleanup handler for the thread. Basic Usage Example: pthread_cleanup_push(handler, argument);
pthread_setcancelstate()
Purpose: To set the cancelability state of the calling thread. Basic Usage Example: pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pthread_attr_init()
Purpose: To initialize thread attributes to default values. Basic Usage Example: pthread_attr_init(&attr);
pthread_cond_broadcast()
Purpose: To unblock all threads currently blocked on the specified condition variable. Basic Usage Example: pthread_cond_broadcast(&cond);
pthread_attr_setdetachstate()
Purpose: To set the detach state attribute of a thread. Basic Usage Example: pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
pthread_barrier_init()
Purpose: To initialize a thread barrier. Basic Usage Example: pthread_barrier_init(&barrier, NULL, 3);
pthread_mutex_unlock()
Purpose: To release a mutex lock after a critical section is executed. Basic Usage Example: pthread_mutex_unlock(&mutex);
pthread_self()
Purpose: To obtain the ID of the calling thread. Basic Usage Example: pthread_t this_thread = pthread_self();
pthread_key_create()
Purpose: To create thread-specific data keys. Basic Usage Example: pthread_key_create(&key, destructor);
pthread_cancel()
Purpose: To request that a thread be canceled. Basic Usage Example: pthread_cancel(thread);
pthread_mutex_lock()
Purpose: To acquire a mutex lock for critical section protection. Basic Usage Example: pthread_mutex_lock(&mutex);
pthread_setspecific()
Purpose: To associate a thread-specific value with a key. Basic Usage Example: pthread_setspecific(key, pointer);
pthread_getspecific()
Purpose: To retrieve the value associated with a thread-specific key. Basic Usage Example: pointer = pthread_getspecific(key);
pthread_barrier_wait()
Purpose: To synchronize participating threads at the barrier. Basic Usage Example: pthread_barrier_wait(&barrier);
pthread_setcanceltype()
Purpose: To set the cancelability type of the calling thread. Basic Usage Example: pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
© Hypatia.Tech. 2024 All rights reserved.