Advanced Programming in the UNIX® Environment
ptg10805159 Section 12.3 Thread Attributes 427 An initialization function exists to set the attributes to their default values. ...
ptg10805159 428 Thread Control Chapter 12 If we know that we don’t need the thread’s termination status at the time we create th ...
ptg10805159 Section 12.3 Thread Attributes 429 return frompthread_attr_destroy,the worst that can happen is that we leak a small ...
ptg10805159 430 Thread Control Chapter 12 #include <pthread.h> int pthread_attr_getstacksize(const pthread_attr_t *restric ...
ptg10805159 Section 12.4 Synchronization Attributes 431 PTHREAD_MUTEX_INITIALIZERconstant or by calling thepthread_mutex_init fu ...
ptg10805159 432 Thread Control Chapter 12 restrict the moreexpensive implementation to the case in which mutexes areshared among ...
ptg10805159 Section 12.4 Synchronization Attributes 433 #include <pthread.h> int pthread_mutex_consistent(pthread_mutex_t ...
ptg10805159 434 Thread Control Chapter 12 We can use thepthread_mutexattr_gettypefunction to get the mutextype attribute. Tochan ...
ptg10805159 Section 12.4 Synchronization Attributes 435 main func1(x) func2(x) func1 pthread_mutex_lock(x->lock) func2(x) pth ...
ptg10805159 436 Thread Control Chapter 12 main func1(x) func2(x) func1 pthread_mutex_lock(x->lock) func2_locked(x) pthread_mu ...
ptg10805159 Section 12.4 Synchronization Attributes 437 void *to_arg; /* argument */ struct timespec to_wait; /* time to wait */ ...
ptg10805159 438 Thread Control Chapter 12 tip->to_wait.tv_sec--; tip->to_wait.tv_nsec = SECTONSEC - now.tv_nsec + when-> ...
ptg10805159 Section 12.4 Synchronization Attributes 439 *Calculate the absolute time when we want to retry. */ clock_gettime(CLO ...
ptg10805159 440 Thread Control Chapter 12 The only attribute supported for reader–writer locks is theprocess-sharedattribute. It ...
ptg10805159 Section 12.4 Synchronization Attributes 441 clock IDs listed in Figure6.8. Wecan use thepthread_condattr_getclockfun ...
ptg10805159 442 Thread Control Chapter 12 The value of theprocess-sharedattribute can be eitherPTHREAD_PROCESS_SHARED (accessibl ...
ptg10805159 Section 12.5 Reentrancy 443 thread-safe versions of these functions. The functions have the same names as their non- ...
ptg10805159 444 Thread Control Chapter 12 #include <stdio.h> int getchar_unlocked(void); int getc_unlocked(FILE *fp); Both ...
ptg10805159 Section 12.5 Reentrancy 445 We show a reentrant version of getenvin Figure12.12. This version is called getenv_r.Itu ...
ptg10805159 446 Thread Control Chapter 12 To makegetenv_rreentrant, we changed the interface so that the caller must provide its ...
«
19
20
21
22
23
24
25
26
27
28
»
Free download pdf