Back to index

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

Go to the source code of this file.

Defines

#define TEST_FUNCTION   do_test ()

Functions

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

Variables

static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 82 of file tst-join1.c.


Function Documentation

static int do_test ( void  ) [static]

Definition at line 57 of file tst-join1.c.

{
  pthread_t th;

  if (pthread_mutex_lock (&lock) != 0)
    {
      puts ("1st lock failed");
      exit (1);
    }

  if (pthread_create (&th, NULL, tf, (void *) pthread_self ()) != 0)
    {
      puts ("create failed");
      exit (1);
    }

  if (pthread_mutex_lock (&lock) != 0)
    {
      puts ("2nd lock failed");
      exit (1);
    }

  pthread_exit ((void *) 42);
}

Here is the call graph for this function:

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

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

{
  pthread_t mh = (pthread_t) arg;
  void *result;

  if (pthread_mutex_unlock (&lock) != 0)
    {
      puts ("unlock failed");
      exit (1);
    }

  if (pthread_join (mh, &result) != 0)
    {
      puts ("join failed");
      exit (1);
    }

  if (result != (void *) 42l)
    {
      printf ("result wrong: expected %p, got %p\n", (void *) 42, result);
      exit (1);
    }

  exit (0);
}

Here is the call graph for this function:


Variable Documentation

Definition at line 25 of file tst-join1.c.