source: rtems/testsuites/psxtmtests/psxtmthread05/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.2 KB
RevLine 
[db08c38]1/*
[50162e0]2 *  COPYRIGHT (c) 1989-2013.
[db08c38]3 *  On-Line Applications Research Corporation (OAR).
4 *  COPYRIGHT (c) 2013.
5 *
6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
[c499856]8 *  http://www.rtems.org/license/LICENSE.
[db08c38]9 */
10
11#ifdef HAVE_CONFIG_H
12#include "config.h"
13#endif
14
15#include <timesys.h>
16#include <pthread.h>
17#include <sched.h>
[8fbe2e6]18#include <rtems/btimer.h>
[db08c38]19#include "test_support.h"
20
[fd46711]21const char rtems_test_name[] = "PSXTMTHREAD 05";
22
[db08c38]23/* forward declarations to avoid warnings */
24void *POSIX_Init(void *argument);
25void benchmark_pthread_create(void);
26void benchmark_pthread_setschedparam(void);
27void *test_thread(void *argument);
28
29void benchmark_pthread_setschedparam(void)
30{
31  int status;
32  int policy;
33  struct sched_param param;
34  pthread_t thread_ID;
35
36  status = pthread_create(&thread_ID, NULL, test_thread, NULL);
37  rtems_test_assert( status == 0 );
38
39  /* make test_thread equal to POSIX_Init() */
40  pthread_getschedparam(pthread_self(), &policy, &param);
[e9a1c99]41 
[db08c38]42  pthread_setschedparam(thread_ID, policy, &param);
43  /* At this point, we've switched to test_thread */
44
45  /* Back from test_thread, switch to test_thread again */
[e9a1c99]46  param.sched_priority = sched_get_priority_min(policy);
[db08c38]47
48  benchmark_timer_initialize();
[e9a1c99]49  //lower own priority to minimun, scheduler forces an involuntary context switch
50  pthread_setschedparam(pthread_self(), policy, &param);
[db08c38]51}
52
53void *test_thread(
54  void *argument
55)
56{
[de549c3]57  uint32_t end_time;
58
[db08c38]59  sched_yield();
60
61  end_time = benchmark_timer_read();
62  put_time(
[50162e0]63    "pthread_setschedparam: lower own priority preempt",
[db08c38]64    end_time,
65    1,        /* Only executed once */
66    0,
67    0
68  );
69
[fd46711]70  TEST_END();
[db08c38]71  rtems_test_exit(0);
72  //Empty thread used in pthread_create().
73  return NULL;
74}
75
76void *POSIX_Init(
77  void *argument
78)
79{
80
[fd46711]81  TEST_BEGIN();
[db08c38]82  benchmark_pthread_setschedparam();
83
84  rtems_test_assert( 1 );
85  return NULL;
86}
87
88/* configuration information */
89
90#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
91#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
92
93#define CONFIGURE_MAXIMUM_POSIX_THREADS     2
94#define CONFIGURE_POSIX_INIT_THREAD_TABLE
95
96#define CONFIGURE_INIT
97
98#include <rtems/confdefs.h>
99/* end of file */
Note: See TracBrowser for help on using the repository browser.