Back to index

glibc  2.9
Defines | Functions | Variables
tst-rwlock5.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.

Defines

#define EXPECTED_SIGNAL   SIGALRM
#define TEST_FUNCTION   do_test ()

Functions

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

Variables

static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER
static pthread_rwlock_t r

Define Documentation

#define EXPECTED_SIGNAL   SIGALRM

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

#define TEST_FUNCTION   do_test ()

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


Function Documentation

static int do_test ( void  ) [static]

Definition at line 47 of file tst-rwlock5.c.

{
  pthread_t th;

  if (pthread_rwlock_init (&r, NULL) != 0)
    {
      puts ("rwlock_init failed");
      return 1;
    }

  if (pthread_rwlock_wrlock (&r) != 0)
    {
      puts ("rwlock_wrlock failed");
      return 1;
    }

  if (pthread_mutex_lock (&m) != 0)
    {
      puts ("mutex_lock failed");
      return 1;
    }

  /* Set an alarm for 1 second.  The wrapper will expect this.  */
  alarm (1);

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

  /* This call should never return.  */
  pthread_mutex_lock (&m);

  puts ("2nd mutex_lock returned");
  return 1;
}

Here is the call graph for this function:

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

Definition at line 32 of file tst-rwlock5.c.

{
  if (pthread_rwlock_wrlock (&r) == 0)
    {
      puts ("child: rwlock_wrlock succeeded");
      exit (1);
    }

  puts ("child: rwlock_wrlock returned");

  exit (1);
}

Here is the call graph for this function:


Variable Documentation

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

pthread_rwlock_t r [static]

Definition at line 28 of file tst-rwlock5.c.