Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced UNIX programming

Similar presentations


Presentation on theme: "Advanced UNIX programming"— Presentation transcript:

1 Advanced UNIX programming
Fall 2002 Instructor: Ashok Srinivasan Lecture 32 Acknowledgements: The syllabus and power point presentations are modified versions of those by T. Baker and X. Yuan

2 Announcements Reading assignment Project Assignment 3 Chapter 23
One page accomplishments report Due Friday, 15 Nov 2002 Assignment 3 Test client and parameters available

3 Week 12 Topics Threads Basic thread functions
Some more thread functions Thread-specific data Mutual exclusion Conditional variables

4 Thread-specific data Thread specific global data
Regular global data is shared by all threads We need to use them very carefully to avoid creating bugs See example1.c, example2.c, and example3.c Pthreads has a means to create thread specific global data “Global variables” that are not shared by other threads It is a common technique for making an existing function thread safe See example4.c Corrects errors in example2.c and example3.c

5 Thread-specific data (continued)
int pthread_once(pthread_once_t *oneptr, void (*init)(void)); int pthread_key_create(pthread_key_t *keyptr, void (*destructor) (void *pointer)); void *pthread_getspecific(pthread_key_t key); int pthread_setspecific(pthread_key_t key, const void *value); See example4.c for the use of these functions


Download ppt "Advanced UNIX programming"

Similar presentations


Ads by Google