source: rtems/testsuites/psxtmtests/psxtmthread02/init.c @ adc2301

4.115
Last change on this file since adc2301 was adc2301, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 30, 2013 at 10:06:07 PM

psxtmthread02/init.c: Fix warnings

  • Property mode set to 100644
File size: 2.0 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.com/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <timesys.h>
15#include <pthread.h>
16#include <sched.h>
17#include <rtems/timerdrv.h>
18#include "test_support.h"
19
20/* forward declarations to avoid warnings */
21void *POSIX_Init(void *argument);
22void benchmark_pthread_create(void);
23void *thread(void *argument);
24
25void benchmark_pthread_create(void)
26{
27  int  status;
28  pthread_t thread_ID;
29  pthread_attr_t attr;
30  struct sched_param param;
31
32  status = pthread_attr_init(&attr);
33  rtems_test_assert( status == 0 );
34
35  status = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
36  rtems_test_assert( status == 0 );
37
38  status = pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
39  rtems_test_assert( status == 0 );
40
41  param.sched_priority = sched_get_priority_max(SCHED_FIFO) - 1;
42  status = pthread_attr_setschedparam(&attr, &param);
43  rtems_test_assert( status == 0 );
44
45  /* create second thread with max priority and get preempted on creation */
46  benchmark_timer_initialize();
47  status = pthread_create(&thread_ID, &attr, thread, NULL);
48}
49
50void *thread(
51  void *argument
52)
53{
54  long end_time;
55
56  end_time = benchmark_timer_read();
57  put_time(
58    "pthread_create - preempt",
59    end_time,
60    1,        /* Only executed once */
61    0,
62    0
63  );
64  return NULL;
65}
66
67void *POSIX_Init(
68  void *argument
69)
70{
71
72  puts( "\n\n*** POSIX TIME TEST PSXTMTHREAD02 ***" );
73
74  benchmark_pthread_create();
75
76  puts( "*** END OF POSIX TIME TEST PSXTMTHREAD02 ***" );
77  rtems_test_exit(0);
78}
79
80/* configuration information */
81
82#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
83#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
84
85#define CONFIGURE_MAXIMUM_POSIX_THREADS     2
86#define CONFIGURE_POSIX_INIT_THREAD_TABLE
87
88#define CONFIGURE_INIT
89
90#include <rtems/confdefs.h>
91/* end of file */
Note: See TracBrowser for help on using the repository browser.