14-Concurrent_Programming_II

14-Concurrent_Programming_II - CSC 4304 - Systems...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CSC 4304 - Systems Programming Fall 2010 Tevfik Ko ! ar Louisiana State University November 2nd, 2010 Lecture - XIV Concurrent Programming Concurrency Issues 2 Concurrency Issues 3 4 Synchronization • Mechanism that allows the programmer to control the relative order in which operations occur in different threads or processes. Critical Section 5 Busy Waiting 6
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Suspend and Resume 7 Mutual Exclusion 8 Mutual Exclusion: Problem 1 9 Mutual Exclusion: Problem 2 10 Mutual Exclusion: Problem 2 11 Mutual Exclusion: Problem 3 12
Background image of page 2
Mutual Exclusion: Problem 3 13 Mutual Exclusion: Solution 14 POSIX Threads: MUTEX int pthread_mutex_init( pthread_mutex_t *mutex , const pthread_mutexattr_t *mutexattr ); int pthread_mutex_lock( pthread_mutex_t *mutex ); int pthread_mutex_unlock( pthread_mutex_t *mutex ); int pthread_mutex_destroy( pthread_mutex_t *mutex ); •a new data type named pthread_mutex_t is designated for mutexes •a mutex is like a key (to access the code section) that is handed to only one thread at a time •the attribute of a mutex can be controlled by using the pthread_mutex_init() function •the lock/unlock functions work in tandem 15 MUTEX Example #include <pthread.h> ... pthread_mutex_t my_mutex;
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

14-Concurrent_Programming_II - CSC 4304 - Systems...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online