source: rtems/testsuites/psxtmtests/psxtmcond04/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
Line 
1/*
2 *  COPYRIGHT (c) 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 04";
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
36  uint32_t end_time;
37  struct   sched_param param;
38  int      policy;
39  int      status;
40
41  status = pthread_mutex_lock(&MutexID);
42  rtems_test_assert( status == 0 );
43  status = pthread_getschedparam(pthread_self(), &policy, &param);
44  rtems_test_assert( status == 0 );
45  param.sched_priority = sched_get_priority_max(policy) - 1;
46  status = pthread_setschedparam(pthread_self(), policy, &param);
47  /* Thread blocks, unlocks mutex, waits for CondID to be signaled */
48  pthread_cond_wait(&CondID,&MutexID);
49
50  /* Once signaled, this thread preempts POSIX_Init thread */
51  end_time = benchmark_timer_read();
52  put_time(
53    "pthread_cond_signal: thread waiting preempt",
54    end_time,
55    1,
56    0,
57    0
58  );
59  TEST_END();
60  rtems_test_exit( 0 );
61  return NULL;
62}
63
64void *POSIX_Init(
65  void *argument
66)
67{
68  int        status;
69  pthread_t  threadId;
70
71  TEST_BEGIN();
72
73  status = pthread_create( &threadId, NULL, Blocker, NULL );
74  rtems_test_assert( status == 0 );
75 
76  status = pthread_mutex_init(&MutexID, NULL);
77  rtems_test_assert( status == 0 );
78
79  status = pthread_cond_init(&CondID, NULL); /* Create condition variable */
80  rtems_test_assert( status == 0 );
81
82  /*
83   * Let the other thread start so the thread startup overhead,
84   * is accounted for.  When we return, we can start the benchmark.
85   */
86  sched_yield();
87  /* let other thread run */
88
89  /* Other thread is blocked and waiting on condition to be signaled */
90  benchmark_timer_initialize();
91  status = pthread_cond_signal(&CondID);
92  rtems_test_assert ( status == 0 );
93  return NULL;
94}
95
96/* configuration information */
97
98#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
99#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
100
101#define CONFIGURE_MAXIMUM_POSIX_THREADS     2
102#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 2
103#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 2
104#define CONFIGURE_POSIX_INIT_THREAD_TABLE
105
106#define CONFIGURE_INIT
107
108#include <rtems/confdefs.h>
109  /* end of file */
Note: See TracBrowser for help on using the repository browser.