Back to index

glibc  2.9
Defines | Functions | Variables
tst-basic3.c File Reference
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "../test-skeleton.c"

Go to the source code of this file.


#define N   20
#define TEST_FUNCTION   do_test ()


static void final_test (void)
static void * tf (void *a)
int do_test (void)


static int nrunning = 1

Define Documentation

Definition at line 85 of file tst-basic3.c.

#define N   20
#define TEST_FUNCTION   do_test ()

Definition at line 86 of file tst-basic3.c.


Function Documentation

int do_test ( void  )

Definition at line 56 of file tst-basic3.c.

#define N 20
  pthread_t t[N];
  pthread_t last = pthread_self ();
  int i;

  atexit (final_test);

  printf ("starting %d + 1 threads\n", N);
  for (i = 0; i < N; ++i)
      if (pthread_create (&t[i], NULL, tf, (void *) last) != 0)
         puts ("create failed");
         _exit (1);


      last = t[i];

  printf ("%2d left\n", --nrunning);

  pthread_exit (NULL);

Here is the call graph for this function:

static void final_test ( void  ) [static]

Definition at line 31 of file tst-basic3.c.

  puts ("final_test has been called");

  kill (getpid (), SIGUSR1);

Here is the call graph for this function:

Here is the caller graph for this function:

static void* tf ( void *  a) [static]

Definition at line 41 of file tst-basic3.c.

  if (pthread_join ((pthread_t) a, NULL) != 0)
      printf ("join failed while %d are running\n", nrunning);
      _exit (1);

  printf ("%2d left\n", --nrunning);

  return NULL;

Here is the call graph for this function:

Variable Documentation

int nrunning = 1 [static]

Definition at line 27 of file tst-basic3.c.