Rec10-2010 - Recitation 10 Thread synchronization...

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

View Full Document Right Arrow Icon
Recitation 10 Thread synchronization primitives
Background image of page 1

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

View Full DocumentRight Arrow Icon
Resource Sharing-Background What are resources ? Why to share them ? Pros Cons What is a critical Section ?
Background image of page 2
Critical Section: An example int x=6; int buf[100]; //global //thread code int count=2; int i; for(i=0;i<100;i++){ buf[i]=buf[i]+x+count; count++; } printf(“COUNT IS:%d”,count);
Background image of page 3

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

View Full DocumentRight Arrow Icon
Synchronization functions for pthread Description POSIX Function Mutex lock Pthread_mutex_init Pthread_mutex_destroy Pthread_mutex_lock Pthread_mutex_trylock Pthread_mutex_unlock Condition Variables Pthread_cond_init Pthread_cond_destroy Pthread_cond_wait Pthread_cond_signal Pthread_cond_broadcast Pthread_cond_timedwait Read-write locks pthread_rwlock_init pthread_rwlock_destroy pthread_rwlock_rdlock pthread_rwlock_wrlock pthread_rwlock_tryrdlock pthread_rwlock_trywrlock pthread_rwlock_timed_rdlock pthread_rwlock_timed_wrlock Taken from: UNIX systems programming communication, concurrency, and threads by Robbins, Kay A. Robbins, Steven
Background image of page 4
Mutex Lock Two state: Locked Unlocked Exclusive access Recommended to be held for short periods
Background image of page 5

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

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

This note was uploaded on 10/21/2011 for the course CSCI 4061 taught by Professor Tripathi during the Spring '08 term at Minnesota.

Page1 / 14

Rec10-2010 - Recitation 10 Thread synchronization...

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

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