{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

2006-1 P4 --- - PONTIFICIA UNIVERSIDAD CATLICA DEL PER...

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

View Full Document Right Arrow Icon
INF231 - Sistemas Operativos Práctica 4 (2006-1) 1 PONTIFICIA UNIVERSIDAD CATÓLICA DEL PERÚ FACULTAD DE CIENCIAS E INGENIERÍA SISTEMAS OPERATIVOS (4ta hoja de trabajos prácticos) (1er período de 2006) Horarios 0881, 0883: Prof. V. Khlebnikov Duración: 1 h. 50 min. The QNX Neutrino Microkernel: Barriers A barrier is a synchronization mechanism that lets you "corral" several cooperating threads (e.g. in a matrix computation), forcing them to wait at a specific point until all have finished before any one thread can continue. Unlike the pthread_join() function, where you'd wait for the threads to terminate, in the case of a barrier you're waiting for the threads to rendezvous at a certain point. When the specified number of threads arrive at the barrier, we unblock all of them so they can continue to run. You first create a barrier with pthread_barrier_init() : #include <pthread.h> int pthread_barrier_init (pthread_barrier_t * barrier , const pthread_barrierattr_t * attr , unsigned int count ); This creates a barrier object at the passed address (a pointer to the barrier object is in barrier ), with the attributes as specified by attr . The count member holds the number of threads that must call pthread_barrier_wait() . Once the barrier is created, each thread will call pthread_barrier_wait() to indicate that it has completed: #include <pthread.h> int pthread_barrier_wait (pthread_barrier_t * barrier ); When a thread calls pthread_barrier_wait() , it blocks until the number of threads specified initially in the pthread_barrier_init() function have called pthread_barrier_wait() (and blocked also). When the correct number of threads
Background image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}