source: rtems/testsuites/psxtmtests/psxtmthread02/init.c @ 115e059

4.11
Last change on this file since 115e059 was 115e059, checked in by Daniel Ramirez <javamonn@…>, on Nov 30, 2013 at 9:42:38 PM

fixed psxtmthread02 test, updated .csv to be in sync and added test .docs

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