source: rtems/testsuites/psxtests/psxcond01/init.c @ 2b36355b

4.115
Last change on this file since 2b36355b was 6c2de60, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/12 at 19:12:11

psxtests - Eliminate missing prototype warnings

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include "tmacros.h"
15#include <pthread.h>
16#include <errno.h>
17
18/* forward declarations to avoid warnings */
19void *POSIX_Init(void *argument);
20void *BlockingThread(void *argument);
21
22pthread_cond_t  Condition;
23pthread_mutex_t Mutex1;
24pthread_mutex_t Mutex2;
25
26void *BlockingThread(
27  void *argument
28)
29{
30  puts( "BlockingThread - pthread_cond_wait on Mutex1 - OK" );
31  (void) pthread_cond_wait( &Condition, &Mutex1 );
32
33  puts( "ERROR - BlockingThread returned from pthread_cond_wait!" );
34  rtems_test_exit( 0 );
35
36  return NULL;
37}
38
39void *POSIX_Init(
40  void *argument
41)
42{
43  int        sc;
44  pthread_t  Thread;
45
46  puts( "\n\n*** POSIX TEST -- CONDITION VARIABLE 01 ***" );
47
48  puts( "Init - pthread_mutex_init - Mutex1 - OK" );
49  sc = pthread_mutex_init( &Mutex1, NULL );
50  fatal_posix_service_status( sc, 0, "mutex1 create ok" );
51
52  puts( "Init - pthread_mutex_init - Mutex2 - OK" );
53  sc = pthread_mutex_init( &Mutex2, NULL );
54  fatal_posix_service_status( sc, 0, "mutex2 create ok" );
55
56  puts( "Init - pthread_cond_init - Condition - OK" );
57  sc = pthread_cond_init( &Condition, NULL );
58  fatal_posix_service_status( sc, 0, "Condition create ok" );
59
60  puts( "Init -  pthread_create - OK" );
61  sc = pthread_create( &Thread, NULL, BlockingThread, NULL );
62  fatal_posix_service_status( sc, 0, "Thread create ok" );
63
64  puts( "Init - sleep to let BlockingThread run" );
65  sleep(1);
66
67  puts( "Init - pthread_cond_wait on Mutex2 - EINVAL" );
68  sc = pthread_cond_wait( &Condition, &Mutex2 );
69  fatal_posix_service_status( sc, EINVAL, "cond_wait EINVAL" );
70
71  puts( "*** END OF POSIX TEST CONDITION VARIABLE 01 ***" );
72  rtems_test_exit( 0 );
73
74  return NULL; /* just so the compiler thinks we returned something */
75}
76
77#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
78#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
79
80#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
81#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 2
82#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 1
83
84#define CONFIGURE_POSIX_INIT_THREAD_TABLE
85
86#define CONFIGURE_INIT
87#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.