Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created November 24, 2011 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raynos/1392354 to your computer and use it in GitHub Desktop.
Save Raynos/1392354 to your computer and use it in GitHub Desktop.
void * thread_start(void *arg) {
while (1) {
/* for each column. Only run columns the thread_num
is assigned to */
for (column_count = thread_num; column_count < dim - 1; column_count+=threads) {
/* do thread work for data chunk */
}
/* barrier */
barrier_result = pthread_barrier_wait(barrier);
if (not_finished == 0) {
/* finished */
break;
/* break while loop, end thread.
The barrier is now broken because it is no longer
getting called by this thread */
}
/* we are not finished, loop around and do thread work on next data chunk */
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment