source: rtems/testsuites/psxtmtests/psxtmthread02/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: 1.9 KB
RevLine 
[408a16e]1/*
[115e059]2 *  COPYRIGHT (c) 1989-2013.
[408a16e]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.
[408a16e]8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <timesys.h>
15#include <pthread.h>
[adc2301]16#include <sched.h>
[8fbe2e6]17#include <rtems/btimer.h>
[408a16e]18#include "test_support.h"
19
[fd46711]20const char rtems_test_name[] = "PSXTMTHREAD 02";
21
[408a16e]22/* forward declarations to avoid warnings */
23void *POSIX_Init(void *argument);
24void benchmark_pthread_create(void);
[7b369af]25void *thread(void *argument);
[408a16e]26
27void benchmark_pthread_create(void)
28{
29  int  status;
30  pthread_t thread_ID;
[115e059]31  pthread_attr_t attr;
32  struct sched_param param;
33
[adc2301]34  status = pthread_attr_init(&attr);
35  rtems_test_assert( status == 0 );
36
37  status = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
38  rtems_test_assert( status == 0 );
39
40  status = pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
41  rtems_test_assert( status == 0 );
42
[115e059]43  param.sched_priority = sched_get_priority_max(SCHED_FIFO) - 1;
[adc2301]44  status = pthread_attr_setschedparam(&attr, &param);
45  rtems_test_assert( status == 0 );
[408a16e]46
[115e059]47  /* create second thread with max priority and get preempted on creation */
[408a16e]48  benchmark_timer_initialize();
[115e059]49  status = pthread_create(&thread_ID, &attr, thread, NULL);
50}
[408a16e]51
[115e059]52void *thread(
53  void *argument
54)
55{
[de549c3]56  uint32_t end_time;
[408a16e]57
[115e059]58  end_time = benchmark_timer_read();
[408a16e]59  put_time(
[50162e0]60    "pthread_create: preempt",
[408a16e]61    end_time,
62    1,        /* Only executed once */
63    0,
64    0
65  );
[7b369af]66  return NULL;
[408a16e]67}
68
69void *POSIX_Init(
70  void *argument
71)
72{
73
[fd46711]74  TEST_BEGIN();
[408a16e]75
76  benchmark_pthread_create();
77
[fd46711]78  TEST_END();
[408a16e]79  rtems_test_exit(0);
80}
81
82/* configuration information */
83
84#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
85#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
86
87#define CONFIGURE_MAXIMUM_POSIX_THREADS     2
88#define CONFIGURE_POSIX_INIT_THREAD_TABLE
89
90#define CONFIGURE_INIT
91
92#include <rtems/confdefs.h>
93/* end of file */
Note: See TracBrowser for help on using the repository browser.