At the end we will tie all of these ideas together by

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: rate. For example, we use threads in our research to implement parallel simulations of earthquakes. The duration of the earthquake (say 60 seconds) is broken up into thousands of tiny timesteps. Each thread runs on a separate processor and models the propagation of seismic waves through some chunk of the earth, first for timestep 1, then for timestep 2, and so on. In order to get consistent results, each thread must finish simulating timestep before the others can begin simulating timestep · ½. We guarantee this by placing a barrier between the execution of each timestep. Our barrier implementation uses a signaling variant called pthread cond broadcast that wakes up every thread currently waiting on condition variable cond. #include <pthread.h> int pthread cond broadcast(pthread cond t *cond); returns: 0 if OK, nonzero on error Figure 11.22 shows the code for a simple barrier package based on mutex and condition variables. The barrier package uses 4 global variables that are defined in lines 2–7. The variab...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online