source: rtems/testsuites/psxtmtests/psxtmcond03/init.c @ 8fbe2e6

4.115
Last change on this file since 8fbe2e6 was 8fbe2e6, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/14 at 13:59:49

Use correct prototype of benchmark_timer_read()

This change starts with removing the effectively empty file
timerdrv.h. The prototypes for benchmark_timer_XXX() were in
btimer.h which was not universally used. Thus every use of
timerdrv.h had to be changed to btimer.h. Then the prototypes
for benchmark_timer_read() had to be adjusted to return
benchmark_timer_t rather than int or uint32_t.

I took this opportunity to also correct the file headers to
separate the copyright from the file description comments which
is needed to ensure the copyright isn't propagated into Doxygen
output.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2013.
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.org/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/btimer.h>
21
22const char rtems_test_name[] = "PSXTMCOND 03";
23
24/* forward declarations to avoid warnings */
25void *POSIX_Init(void *argument);
26void *Blocker(void *argument);
27
28pthread_mutex_t MutexID;
29pthread_cond_t CondID;
30
31void *Blocker(
32  void *argument
33)
34{
35  int status;
36
37  status = pthread_mutex_lock(&MutexID);
38  rtems_test_assert( status == 0 );
39 
40  /* Unlock mutex, block, wait for CondID to be signaled */
41  pthread_cond_wait(&CondID,&MutexID);
42 
43 /* should never return */
44  rtems_test_assert( FALSE );
45
46  return NULL;
47}
48
49void *POSIX_Init(
50  void *argument
51)
52{
53  int        status;
54  pthread_t  threadId;
55  uint32_t   end_time;
56  struct sched_param param;
57  int policy;
58
59  TEST_BEGIN();
60
61  status = pthread_create( &threadId, NULL, Blocker, NULL );
62  rtems_test_assert( status == 0 );
63 
64  status = pthread_mutex_init(&MutexID, NULL);
65  rtems_test_assert( status == 0 );
66
67  status = pthread_cond_init(&CondID, NULL); /* Create condition variable */
68  rtems_test_assert( status == 0 );
69
70  /*
71   * Let the other thread start so the thread startup overhead,
72   * is accounted for.  When we return, we can start the benchmark.
73   */
74  sched_yield();
75    /* let other thread run */
76
77  /* To be extra sure we don't get preempted on the signal */
78  status = pthread_getschedparam(pthread_self(), &policy, &param);
79  rtems_test_assert( status == 0);
80  param.sched_priority = sched_get_priority_max(policy) - 1;
81  status = pthread_setschedparam(pthread_self(), policy, &param);
82  rtems_test_assert( status == 0);
83
84  benchmark_timer_initialize();
85  status = pthread_cond_signal(&CondID);
86  end_time = benchmark_timer_read();
87  rtems_test_assert( status == 0 );
88
89  put_time(
90    "pthread_cond_signal: thread waiting no preempt",
91    end_time,
92    1,
93    0,
94    0
95  );
96
97  TEST_END();
98  rtems_test_exit( 0 );
99
100  return NULL;
101}
102
103/* configuration information */
104
105#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
106#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
107
108#define CONFIGURE_MAXIMUM_POSIX_THREADS     2
109#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 2
110#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 2
111#define CONFIGURE_POSIX_INIT_THREAD_TABLE
112
113#define CONFIGURE_INIT
114
115#include <rtems/confdefs.h>
116  /* end of file */
Note: See TracBrowser for help on using the repository browser.