Back to index

glibc  2.9
Defines | Functions
ex9.c File Reference
#include <errno.h>
#include <error.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

Go to the source code of this file.

Defines

#define NUM_THREADS   10
#define NUM_ITERS   500

Functions

static void * thread (void *)

Define Documentation

#define NUM_ITERS   500

Definition at line 27 of file ex9.c.

#define NUM_THREADS   10

Definition at line 26 of file ex9.c.


Function Documentation

static void * thread ( void *  arg) [static]

Definition at line 29 of file ex9.c.

{
  pthread_t thread_list[NUM_THREADS];
  int i;

  if (pthread_barrier_init (&barrier, NULL, NUM_THREADS + 1) != 0)
    error (EXIT_FAILURE, 0, "cannot initialize barrier");

  for (i = 0; i < NUM_THREADS; i++)
    {
      if (pthread_create (&thread_list[i], NULL, thread, NULL) != 0)
       error (EXIT_FAILURE, 0, "cannot create thread");
    }

  (void) thread (NULL);

  for (i = 0; i < NUM_THREADS; i++)
    {
      pthread_join(thread_list[i], NULL);
    }

  return 0;
}

Here is the call graph for this function: