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

4.11
Last change on this file since 8fbe2e6 was 8fbe2e6, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 4, 2014 at 1:59:49 PM

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
RevLine 
[bcefae2e]1/*
[50162e0]2 *  COPYRIGHT (c) 1989-2013.
[bcefae2e]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
[c499856]7 *  http://www.rtems.org/license/LICENSE.
[bcefae2e]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>
[8fbe2e6]20#include <rtems/btimer.h>
[bcefae2e]21
[fd46711]22const char rtems_test_name[] = "PSXTMCOND 03";
23
[bcefae2e]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{
[72ff756]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 */
[bcefae2e]41  pthread_cond_wait(&CondID,&MutexID);
[72ff756]42 
43 /* should never return */
[bcefae2e]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;
[de549c3]55  uint32_t   end_time;
[72ff756]56  struct sched_param param;
57  int policy;
[bcefae2e]58
[fd46711]59  TEST_BEGIN();
[bcefae2e]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
[72ff756]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
[bcefae2e]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(
[50162e0]90    "pthread_cond_signal: thread waiting no preempt",
[bcefae2e]91    end_time,
92    1,
93    0,
94    0
95  );
96
[fd46711]97  TEST_END();
[bcefae2e]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.