Back to index

glibc  2.9
Defines | Functions | Variables
tst-basic1.c File Reference
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include "../test-skeleton.c"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define N   2
#define TEST_FUNCTION   do_test ()

Functions

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

Variables

static pid_t pid

Define Documentation

#define N   2
#define TEST_FUNCTION   do_test ()

Definition at line 81 of file tst-basic1.c.


Function Documentation

int do_test ( void  )

Definition at line 42 of file tst-basic1.c.

{
  pid = getpid ();

#define N 2
  pthread_t t[N];
  int i;

  for (i = 0; i < N; ++i)
    if (pthread_create (&t[i], NULL, tf, (void *) (long int) (i + 1)) != 0)
      {
       write (2, "create failed\n", 14);
       _exit (1);
      }
    else
      printf ("created thread %d\n", i);

  for (i = 0; i < N; ++i)
    {
      void *r;
      int e;
      if ((e = pthread_join (t[i], &r)) != 0)
       {
         printf ("join failed: %d\n", e);
         _exit (1);
       }
      else if (r != (void *) (long int) (i + 1))
       {
         write (2, "result wrong\n", 13);
         _exit (1);
       }
      else
       printf ("joined thread %d\n", i);
    }

  return 0;
}

Here is the call graph for this function:

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

Definition at line 29 of file tst-basic1.c.

{
  if (getpid () != pid)
    {
      write (2, "pid mismatch\n", 13);
      _exit (1);
    }

  return a;
}

Here is the call graph for this function:


Variable Documentation

pid_t pid [static]

Definition at line 26 of file tst-basic1.c.