source: rtems/testsuites/psxtmtests/psxtmcond03/init.c @ bcefae2e

4.115
Last change on this file since bcefae2e was bcefae2e, checked in by Christopher Kerl <zargyyoyo@…>, on 01/11/13 at 20:15:24

Create POSIX Timing Test psxtmcond03

  • 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 <coverhd.h>
15#include <tmacros.h>
16#include <timesys.h>
17#include "test_support.h"
18#include <pthread.h>
19#include <sched.h>
20#include <rtems/timerdrv.h>
21
22/* forward declarations to avoid warnings */
23void *POSIX_Init(void *argument);
24void *Blocker(void *argument);
25
26pthread_mutex_t MutexID;
27pthread_cond_t CondID;
28
29void *Blocker(
30  void *argument
31)
32{
33  pthread_cond_wait(&CondID,&MutexID);
34  /* should never return */
35  rtems_test_assert( FALSE );
36
37  return NULL;
38}
39
40void *POSIX_Init(
41  void *argument
42)
43{
44  int        status;
45  pthread_t  threadId;
46  long       end_time;
47
48  puts( "\n\n*** POSIX TIME TEST PSXTMCOND03 ***" );
49
50  status = pthread_create( &threadId, NULL, Blocker, NULL );
51  rtems_test_assert( status == 0 );
52 
53  status = pthread_mutex_init(&MutexID, NULL);
54  rtems_test_assert( status == 0 );
55
56  status = pthread_cond_init(&CondID, NULL); /* Create condition variable */
57  rtems_test_assert( status == 0 );
58
59  /*
60   * Ensure the mutex is unavailable so the other threads block.
61   */
62  status = pthread_mutex_lock(&MutexID);
63  rtems_test_assert( status == 0 );
64
65  /*
66   * Let the other thread start so the thread startup overhead,
67   * is accounted for.  When we return, we can start the benchmark.
68   */
69  sched_yield();
70    /* let other thread run */
71
72  benchmark_timer_initialize();
73  status = pthread_cond_signal(&CondID);
74  end_time = benchmark_timer_read();
75  rtems_test_assert( status == 0 );
76
77  put_time(
78    "pthread_cond_signal - thread waiting, no preempt",
79    end_time,
80    1,
81    0,
82    0
83  );
84
85  puts( "*** END OF POSIX TIME TEST PSXTMCOND03 ***" );
86  rtems_test_exit( 0 );
87
88  return NULL;
89}
90
91/* configuration information */
92
93#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
94#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
95
96#define CONFIGURE_MAXIMUM_POSIX_THREADS     2
97#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 2
98#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 2
99#define CONFIGURE_POSIX_INIT_THREAD_TABLE
100
101#define CONFIGURE_INIT
102
103#include <rtems/confdefs.h>
104  /* end of file */
Note: See TracBrowser for help on using the repository browser.