1 / 3

Chap. 23 Threads

Chap. 23 Threads. (1) Threads v.s. Fork. (2) Basic Thread Functions. #include <pthread.h> int pthread_create ( pthread_t *tid , const pthread_attr_t * attr , void *(* func )(void *), void * arg );

geneva
Télécharger la présentation

Chap. 23 Threads

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chap. 23 Threads (1) Threads v.s. Fork (2) Basic Thread Functions #include <pthread.h> int pthread_create ( pthread_t *tid, const pthread_attr_t *attr, void *(*func)(void *), void *arg); int pthread_join ( pthread_t tid, void ** status); pthread_t pthread_self (void); int pthread_detach (pthread_ tid); void pthread_exit (void *status);

  2. (3) Thread-specific Data Thread-specific data per process Thread-specific data items per thread

  3. Functions for Thread-specific Data int pthread_once (pthread_once_t *onceptr, void (*init)(void)); int pthread_key_create(pthread_key_t *keyptr, void (*destructor) (void *value)); void *pthread_getspecific (pthread_key_t key); int pthread_setspecific (pthread_key_t key, const void *value); (4) Mutexes : Mutual Exclusion int pthread_mutex_lock (pthread_mutex_t *mptr); int pthread_mutex_unlock (pthread_mutex_ *mptr); (5) Condition Variables int pthread_cond_wait (pthread_cond_t *cptr, pthread_mutex_ *mptr); int pthread_cond_signal (pthread_cond_t *cptr); int pthread_cond_broadcast (pthread_cond_t *cptr); int pthread_cond_timedwait (pthread_cond_t *cptr, pthread_mutex_t *mptr, const struct timespec *abstime)

More Related